mirror of https://github.com/apache/archiva.git
[MRM-378]: Clicking on the tabs in the artifact detail page doesn't change the view
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@542881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d8738d248
commit
f457d052ae
|
@ -44,6 +44,15 @@ public interface DeclarativeConstraint extends Constraint
|
||||||
* @return the parameters. (can be null)
|
* @return the parameters. (can be null)
|
||||||
*/
|
*/
|
||||||
public abstract String[] getDeclaredParameters();
|
public abstract String[] getDeclaredParameters();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The JDOQL filter to apply to the query. (optional)
|
||||||
|
*
|
||||||
|
* NOTE: This is DAO implementation specific.
|
||||||
|
*
|
||||||
|
* @return the filter to apply. (can be null)
|
||||||
|
*/
|
||||||
|
public abstract String getFilter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parameters used for this query. (required if using {@link #getDeclaredParameters()} )
|
* Get the parameters used for this query. (required if using {@link #getDeclaredParameters()} )
|
||||||
|
@ -67,6 +76,15 @@ public interface DeclarativeConstraint extends Constraint
|
||||||
* @return the sort column name. (can be null)
|
* @return the sort column name. (can be null)
|
||||||
*/
|
*/
|
||||||
public abstract String getSortColumn();
|
public abstract String getSortColumn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the variables used within the query.
|
||||||
|
*
|
||||||
|
* NOTE: This is DAO implementation specific.
|
||||||
|
*
|
||||||
|
* @return the variables used within the query.
|
||||||
|
*/
|
||||||
|
public abstract String[] getVariables();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the SELECT WHERE (condition) value for the constraint.
|
* Get the SELECT WHERE (condition) value for the constraint.
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.archiva.database.browsing;
|
||||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||||
|
import org.apache.maven.archiva.database.constraints.ProjectsByArtifactUsageConstraint;
|
||||||
import org.apache.maven.archiva.database.constraints.UniqueArtifactIdConstraint;
|
import org.apache.maven.archiva.database.constraints.UniqueArtifactIdConstraint;
|
||||||
import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint;
|
import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint;
|
||||||
import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
|
import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
|
||||||
|
@ -30,6 +31,7 @@ import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +113,7 @@ public class DefaultRepositoryBrowsing
|
||||||
{
|
{
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchivaProjectModel model;
|
ArchivaProjectModel model;
|
||||||
|
|
||||||
if ( pomArtifact.getModel().isProcessed() )
|
if ( pomArtifact.getModel().isProcessed() )
|
||||||
|
@ -128,11 +130,11 @@ public class DefaultRepositoryBrowsing
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
model = dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version );
|
model = dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version );
|
||||||
|
|
||||||
if ( model == null )
|
if ( model == null )
|
||||||
{
|
{
|
||||||
throw new ObjectNotFoundException( "Unable to find project model for [" + groupId + ":" + artifactId + ":"
|
throw new ObjectNotFoundException( "Unable to find project model for [" + groupId + ":" + artifactId
|
||||||
+ version + "]" );
|
+ ":" + version + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
|
@ -142,4 +144,19 @@ public class DefaultRepositoryBrowsing
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List getUsedBy( String groupId, String artifactId, String version )
|
||||||
|
throws ArchivaDatabaseException
|
||||||
|
{
|
||||||
|
ProjectsByArtifactUsageConstraint constraint = new ProjectsByArtifactUsageConstraint( groupId, artifactId,
|
||||||
|
version );
|
||||||
|
List results = dao.getProjectModelDAO().queryProjectModels( constraint );
|
||||||
|
if ( results == null )
|
||||||
|
{
|
||||||
|
// defensive. to honor contract as specified. never null.
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,20 +23,63 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RepositoryBrowsing
|
* Repository Browsing component
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public interface RepositoryBrowsing
|
public interface RepositoryBrowsing
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get the {@link BrowsingResults} for the root of the repository.
|
||||||
|
*
|
||||||
|
* @return the root browsing results.
|
||||||
|
*/
|
||||||
public BrowsingResults getRoot();
|
public BrowsingResults getRoot();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link BrowsingResults} for the selected groupId.
|
||||||
|
*
|
||||||
|
* @param groupId the groupId to select.
|
||||||
|
* @return the {@link BrowsingResults} for the specified groupId.
|
||||||
|
*/
|
||||||
public BrowsingResults selectGroupId( String groupId );
|
public BrowsingResults selectGroupId( String groupId );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link BrowsingResults} for the selected groupId & artifactId.
|
||||||
|
*
|
||||||
|
* @param groupId the groupId selected
|
||||||
|
* @param artifactId the artifactId selected
|
||||||
|
* @return the {@link BrowsingResults} for the specified groupId / artifactId combo.
|
||||||
|
*/
|
||||||
public BrowsingResults selectArtifactId( String groupId, String artifactId );
|
public BrowsingResults selectArtifactId( String groupId, String artifactId );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link ArchivaProjectModel} for the selected groupId / artifactId / version combo.
|
||||||
|
*
|
||||||
|
* @param groupId the groupId selected
|
||||||
|
* @param artifactId the artifactId selected
|
||||||
|
* @param version the version selected
|
||||||
|
* @return the {@link ArchivaProjectModel} for the selected groupId / artifactId / version combo.
|
||||||
|
* @throws ObjectNotFoundException if the artifact object or project object isn't found in the database.
|
||||||
|
* @throws ArchivaDatabaseException if there is a fundamental database error.
|
||||||
|
*/
|
||||||
public ArchivaProjectModel selectVersion( String groupId, String artifactId, String version )
|
public ArchivaProjectModel selectVersion( String groupId, String artifactId, String version )
|
||||||
throws ObjectNotFoundException, ArchivaDatabaseException;
|
throws ObjectNotFoundException, ArchivaDatabaseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link List} of {@link ArchivaProjectModel} that are used by the provided
|
||||||
|
* groupId, artifactId, and version specified.
|
||||||
|
*
|
||||||
|
* @param groupId the groupId selected
|
||||||
|
* @param artifactId the artifactId selected
|
||||||
|
* @param version the version selected
|
||||||
|
* @return the {@link List} of {@link ArchivaProjectModel} objects. (never null, but can be empty)
|
||||||
|
* @throws ArchivaDatabaseException if there is a fundamental database error.
|
||||||
|
*/
|
||||||
|
public List getUsedBy( String groupId, String artifactId, String version )
|
||||||
|
throws ArchivaDatabaseException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,16 @@ public abstract class AbstractDeclarativeConstraint
|
||||||
protected String[] declImports;
|
protected String[] declImports;
|
||||||
|
|
||||||
protected String[] declParams;
|
protected String[] declParams;
|
||||||
|
|
||||||
|
protected String[] variables;
|
||||||
|
|
||||||
protected Object[] params;
|
protected Object[] params;
|
||||||
|
|
||||||
|
public String getFilter()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFetchLimits()
|
public String getFetchLimits()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -61,4 +68,9 @@ public abstract class AbstractDeclarativeConstraint
|
||||||
{
|
{
|
||||||
return Constraint.ASCENDING;
|
return Constraint.ASCENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getVariables()
|
||||||
|
{
|
||||||
|
return variables;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,12 +31,8 @@ import org.codehaus.plexus.jdo.JdoFactory;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||||
import org.jpox.PMFConfiguration;
|
|
||||||
import org.jpox.SchemaTool;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -80,35 +76,35 @@ public class JdoAccess
|
||||||
pmf = jdoFactory.getPersistenceManagerFactory();
|
pmf = jdoFactory.getPersistenceManagerFactory();
|
||||||
|
|
||||||
/* Primitive (and failed) attempt at creating the schema on startup.
|
/* Primitive (and failed) attempt at creating the schema on startup.
|
||||||
Just to prevent the multiple stack trace warnings on auto-gen of schema.
|
Just to prevent the multiple stack trace warnings on auto-gen of schema.
|
||||||
|
|
||||||
// Create the schema (if needed)
|
// Create the schema (if needed)
|
||||||
URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) };
|
URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) };
|
||||||
|
|
||||||
File propsFile = null; // intentional
|
File propsFile = null; // intentional
|
||||||
boolean verbose = true;
|
boolean verbose = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String connectionFactoryName = pmf.getConnectionFactoryName();
|
String connectionFactoryName = pmf.getConnectionFactoryName();
|
||||||
if ( StringUtils.isNotBlank( connectionFactoryName ) && connectionFactoryName.startsWith( "java:comp" ) )
|
if ( StringUtils.isNotBlank( connectionFactoryName ) && connectionFactoryName.startsWith( "java:comp" ) )
|
||||||
{
|
{
|
||||||
// We have a JNDI datasource!
|
// We have a JNDI datasource!
|
||||||
String jndiDatasource = connectionFactoryName;
|
String jndiDatasource = connectionFactoryName;
|
||||||
System.setProperty( PMFConfiguration.JDO_DATASTORE_URL_PROPERTY, jndiDatasource );
|
System.setProperty( PMFConfiguration.JDO_DATASTORE_URL_PROPERTY, jndiDatasource );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: figure out how to get the jdbc driver details from JNDI to pass into SchemaTool.
|
// TODO: figure out how to get the jdbc driver details from JNDI to pass into SchemaTool.
|
||||||
|
|
||||||
SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null );
|
SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
getLogger().error( "Unable to create schema: " + e.getMessage(), e );
|
getLogger().error( "Unable to create schema: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
pmf.getPersistenceManager();
|
pmf.getPersistenceManager();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Add the lifecycle listener.
|
// Add the lifecycle listener.
|
||||||
pmf.addInstanceLifecycleListener( this, null );
|
pmf.addInstanceLifecycleListener( this, null );
|
||||||
|
@ -324,6 +320,16 @@ public class JdoAccess
|
||||||
Extent extent = pm.getExtent( clazz, true );
|
Extent extent = pm.getExtent( clazz, true );
|
||||||
Query query = pm.newQuery( extent );
|
Query query = pm.newQuery( extent );
|
||||||
|
|
||||||
|
if ( constraint.getFilter() != null )
|
||||||
|
{
|
||||||
|
query.setFilter( constraint.getFilter() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( constraint.getVariables() != null )
|
||||||
|
{
|
||||||
|
query.declareVariables( StringUtils.join( constraint.getVariables(), "; " ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( constraint.getSortColumn() != null )
|
if ( constraint.getSortColumn() != null )
|
||||||
{
|
{
|
||||||
String ordering = constraint.getSortColumn();
|
String ordering = constraint.getSortColumn();
|
||||||
|
|
|
@ -19,10 +19,13 @@ package org.apache.maven.archiva.database;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer;
|
import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer;
|
||||||
import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer;
|
import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer;
|
||||||
import org.apache.maven.archiva.database.updater.TestDatabaseCleanupConsumer;
|
import org.apache.maven.archiva.database.updater.TestDatabaseCleanupConsumer;
|
||||||
import org.apache.maven.archiva.database.updater.TestDatabaseUnprocessedConsumer;
|
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.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
|
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
|
||||||
import org.codehaus.plexus.jdo.JdoFactory;
|
import org.codehaus.plexus.jdo.JdoFactory;
|
||||||
|
@ -163,4 +166,43 @@ public class AbstractArchivaDatabaseTestCase
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat( TIMESTAMP );
|
SimpleDateFormat sdf = new SimpleDateFormat( TIMESTAMP );
|
||||||
return sdf.format( date );
|
return sdf.format( date );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected VersionedReference toVersionedReference( String id )
|
||||||
|
{
|
||||||
|
String parts[] = StringUtils.splitPreserveAllTokens( id, ':' );
|
||||||
|
assertEquals( "Should have 3 parts [" + id + "]", 3, parts.length );
|
||||||
|
|
||||||
|
VersionedReference ref = new VersionedReference();
|
||||||
|
ref.setGroupId( parts[0] );
|
||||||
|
ref.setArtifactId( parts[1] );
|
||||||
|
ref.setVersion( parts[2] );
|
||||||
|
|
||||||
|
assertTrue( "Group ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getGroupId() ) );
|
||||||
|
assertTrue( "Artifact ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getArtifactId() ) );
|
||||||
|
assertTrue( "Version should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getVersion() ) );
|
||||||
|
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArtifactReference toArtifactReference( String id )
|
||||||
|
{
|
||||||
|
String parts[] = StringUtils.splitPreserveAllTokens( id, ':' );
|
||||||
|
assertEquals( "Should have 5 parts [" + id + "]", 5, parts.length );
|
||||||
|
|
||||||
|
ArtifactReference ref = new ArtifactReference();
|
||||||
|
ref.setGroupId( parts[0] );
|
||||||
|
ref.setArtifactId( parts[1] );
|
||||||
|
ref.setVersion( parts[2] );
|
||||||
|
ref.setClassifier( parts[3] );
|
||||||
|
ref.setType( parts[4] );
|
||||||
|
|
||||||
|
assertTrue( "Group ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getGroupId() ) );
|
||||||
|
assertTrue( "Artifact ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getArtifactId() ) );
|
||||||
|
assertTrue( "Version should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getVersion() ) );
|
||||||
|
// Blank string is ok for classifier, NULL is not.
|
||||||
|
assertNotNull( "Classifier should not be null [" + id + "]", ref.getClassifier() );
|
||||||
|
assertTrue( "Type should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getType() ) );
|
||||||
|
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ProjectsByArtifactUsageConstraintTest
|
||||||
|
extends AbstractArchivaDatabaseTestCase
|
||||||
|
{
|
||||||
|
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() );
|
||||||
|
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" );
|
||||||
|
assertConstraint( 2, new ProjectsByArtifactUsageConstraint( artifact ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertConstraint( int expectedHits, DeclarativeConstraint constraint )
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
List results = dao.getProjectModelDAO().queryProjectModels( constraint );
|
||||||
|
assertNotNull( "Projects By Artifact Usage: Not Null", results );
|
||||||
|
assertEquals( "Projects By Artifact Usage: Results.size", expectedHits, results.size() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,13 +26,10 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||||
import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
|
import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
|
||||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||||
import org.apache.maven.archiva.model.ProjectRepository;
|
|
||||||
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
|
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browse the repository.
|
* Browse the repository.
|
||||||
|
@ -144,8 +141,7 @@ public class ShowArtifactAction
|
||||||
{
|
{
|
||||||
this.model = repoBrowsing.selectVersion( groupId, artifactId, version );
|
this.model = repoBrowsing.selectVersion( groupId, artifactId, version );
|
||||||
|
|
||||||
// TODO: create depends on collector.
|
this.dependees = repoBrowsing.getUsedBy( groupId, artifactId, version );
|
||||||
this.dependees = Collections.EMPTY_LIST;
|
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +154,7 @@ public class ShowArtifactAction
|
||||||
{
|
{
|
||||||
this.model = repoBrowsing.selectVersion( groupId, artifactId, version );
|
this.model = repoBrowsing.selectVersion( groupId, artifactId, version );
|
||||||
|
|
||||||
this.dependencyTree = new ArrayList();
|
this.dependencyTree = Collections.EMPTY_LIST;
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -231,6 +227,7 @@ public class ShowArtifactAction
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List getDependees()
|
public List getDependees()
|
||||||
{
|
{
|
||||||
return dependees;
|
return dependees;
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<%--
|
||||||
|
~ 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.
|
||||||
|
--%>
|
||||||
|
|
||||||
|
<%@ taglib prefix="ww" uri="/webwork" %>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
<%-- TODO: paginate! --%>
|
||||||
|
<c:forEach items="${dependees}" var="project">
|
||||||
|
<h3 class="artifact-title">
|
||||||
|
<my:showArtifactTitle groupId="${project.groupId}" artifactId="${project.artifactId}"
|
||||||
|
version="${project.version}"/>
|
||||||
|
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<my:showArtifactLink groupId="${project.groupId}" artifactId="${project.artifactId}"
|
||||||
|
version="${project.version}"/>
|
||||||
|
</p>
|
||||||
|
</c:forEach>
|
||||||
|
<c:if test="${empty(dependees)}">
|
||||||
|
<strong>No results</strong>
|
||||||
|
</c:if>
|
|
@ -146,6 +146,9 @@
|
||||||
<c:when test="${dependencyTree != null}">
|
<c:when test="${dependencyTree != null}">
|
||||||
<%@ include file="/WEB-INF/jsp/include/dependencyTree.jspf" %>
|
<%@ include file="/WEB-INF/jsp/include/dependencyTree.jspf" %>
|
||||||
</c:when>
|
</c:when>
|
||||||
|
<c:when test="${dependees != null}">
|
||||||
|
<%@ include file="/WEB-INF/jsp/include/projectDependees.jspf" %>
|
||||||
|
</c:when>
|
||||||
<c:when test="${mailingLists != null}">
|
<c:when test="${mailingLists != null}">
|
||||||
<%@ include file="/WEB-INF/jsp/include/mailingLists.jspf" %>
|
<%@ include file="/WEB-INF/jsp/include/mailingLists.jspf" %>
|
||||||
</c:when>
|
</c:when>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<%@ taglib prefix="ww" uri="/webwork" %>
|
<%@ taglib prefix="ww" uri="/webwork" %>
|
||||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||||
<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %>
|
<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %>
|
||||||
|
|
||||||
<%@ attribute name="groupId" required="true" %>
|
<%@ attribute name="groupId" required="true" %>
|
||||||
<%@ attribute name="artifactId" %>
|
<%@ attribute name="artifactId" %>
|
||||||
<%@ attribute name="version" %>
|
<%@ attribute name="version" %>
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
<%@ attribute name="versions" type="java.util.List" %>
|
<%@ attribute name="versions" type="java.util.List" %>
|
||||||
|
|
||||||
<span class="artifact-link">
|
<span class="artifact-link">
|
||||||
<archiva:groupIdLink var="${model.groupId}" includeTop="true" />
|
<archiva:groupIdLink var="${groupId}" includeTop="false" />
|
||||||
|
|
||||||
<c:if test="${!empty(artifactId)}">
|
<c:if test="${!empty(artifactId)}">
|
||||||
<c:set var="url">
|
<c:set var="url">
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
<ww:param name="artifactId" value="%{'${artifactId}'}"/>
|
<ww:param name="artifactId" value="%{'${artifactId}'}"/>
|
||||||
</ww:url>
|
</ww:url>
|
||||||
</c:set>
|
</c:set>
|
||||||
/ <a href="${url}">${artifactId}</a>
|
<a href="${url}">${artifactId}</a>
|
||||||
</c:if>
|
</c:if>
|
||||||
| <strong>Version(s):</strong>
|
| <strong>Version(s):</strong>
|
||||||
<c:choose>
|
<c:choose>
|
||||||
|
|
Loading…
Reference in New Issue