mirror of https://github.com/apache/archiva.git
Updating branch with latest work towards database refactor.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@525176 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54e1d8c608
commit
74cb10586c
|
@ -1,75 +0,0 @@
|
|||
package org.apache.maven.archiva.configuration;
|
||||
|
||||
/*
|
||||
* 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.proxy.ProxiedArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Create an artifact repository from the given configuration.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public interface ConfiguredRepositoryFactory
|
||||
{
|
||||
String ROLE = ConfiguredRepositoryFactory.class.getName();
|
||||
|
||||
/**
|
||||
* Create an artifact repository from the given configuration.
|
||||
*
|
||||
* @param configuration the configuration
|
||||
* @return the artifact repository
|
||||
*/
|
||||
ArtifactRepository createRepository( RepositoryConfiguration configuration );
|
||||
|
||||
/**
|
||||
* Create artifact repositories from the given configuration.
|
||||
*
|
||||
* @param configuration the configuration containing the repositories
|
||||
* @return the artifact repositories
|
||||
*/
|
||||
List createRepositories( Configuration configuration );
|
||||
|
||||
/**
|
||||
* Create a local repository from the given configuration.
|
||||
*
|
||||
* @param configuration the configuration
|
||||
* @return the local artifact repository
|
||||
*/
|
||||
ArtifactRepository createLocalRepository( Configuration configuration );
|
||||
|
||||
/**
|
||||
* Create an artifact repository from the given proxy repository configuration.
|
||||
*
|
||||
* @param configuration the configuration
|
||||
* @return the artifact repository
|
||||
*/
|
||||
ProxiedArtifactRepository createProxiedRepository( ProxiedRepositoryConfiguration configuration );
|
||||
|
||||
/**
|
||||
* Create artifact repositories from the given proxy repository configurations.
|
||||
*
|
||||
* @param configuration the configuration containing the repositories
|
||||
* @return the artifact repositories
|
||||
*/
|
||||
List createProxiedRepositories( Configuration configuration );
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
package org.apache.maven.archiva.configuration;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.proxy.ProxiedArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Create artifact repositories from a configuration.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @plexus.component role="org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory"
|
||||
*/
|
||||
public class DefaultConfiguredRepositoryFactory
|
||||
implements ConfiguredRepositoryFactory
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
|
||||
*/
|
||||
private Map repositoryLayouts;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArtifactRepositoryFactory repoFactory;
|
||||
|
||||
public ArtifactRepository createRepository( RepositoryConfiguration configuration )
|
||||
{
|
||||
return createRepository( configuration.getLayout(), configuration.getId(), configuration.getDirectory());
|
||||
}
|
||||
|
||||
public ProxiedArtifactRepository createProxiedRepository( ProxiedRepositoryConfiguration configuration )
|
||||
{
|
||||
boolean enabled = isEnabled( configuration.getSnapshotsPolicy() );
|
||||
String updatePolicy =
|
||||
getUpdatePolicy( configuration.getSnapshotsPolicy(), configuration.getSnapshotsInterval() );
|
||||
ArtifactRepositoryPolicy snapshotsPolicy =
|
||||
new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
||||
|
||||
enabled = isEnabled( configuration.getReleasesPolicy() );
|
||||
updatePolicy = getUpdatePolicy( configuration.getReleasesPolicy(), configuration.getReleasesInterval() );
|
||||
ArtifactRepositoryPolicy releasesPolicy =
|
||||
new ArtifactRepositoryPolicy( enabled, updatePolicy, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
||||
|
||||
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() );
|
||||
|
||||
if ( layout == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Invalid layout: " + configuration.getLayout() );
|
||||
}
|
||||
|
||||
ArtifactRepository artifactRepository = repoFactory.createArtifactRepository( configuration.getId(),
|
||||
configuration.getUrl(), layout,
|
||||
snapshotsPolicy, releasesPolicy );
|
||||
ProxiedArtifactRepository repository = new ProxiedArtifactRepository( artifactRepository );
|
||||
repository.setCacheFailures( configuration.isCacheFailures() );
|
||||
repository.setHardFail( configuration.isHardFail() );
|
||||
repository.setName( configuration.getName() );
|
||||
repository.setUseNetworkProxy( configuration.isUseNetworkProxy() );
|
||||
return repository;
|
||||
}
|
||||
|
||||
public List createRepositories( Configuration configuration )
|
||||
{
|
||||
List managedRepositories = configuration.getRepositories();
|
||||
List repositories = new ArrayList( managedRepositories.size() );
|
||||
|
||||
for ( Iterator i = managedRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
repositories.add( createRepository( (RepositoryConfiguration) i.next() ) );
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
|
||||
public List createProxiedRepositories( Configuration configuration )
|
||||
{
|
||||
List proxiedRepositories = configuration.getProxiedRepositories();
|
||||
List repositories = new ArrayList( proxiedRepositories.size() );
|
||||
|
||||
for ( Iterator i = proxiedRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
repositories.add( createProxiedRepository( (ProxiedRepositoryConfiguration) i.next() ) );
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
|
||||
public ArtifactRepository createLocalRepository( Configuration configuration )
|
||||
{
|
||||
return createRepository( "default", "local", configuration.getLocalRepository() );
|
||||
}
|
||||
|
||||
public ArtifactRepository createRepository( String layout, String id, String directory )
|
||||
{
|
||||
ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) repositoryLayouts.get( layout );
|
||||
File repository = new File( directory );
|
||||
repository.mkdirs();
|
||||
|
||||
String repoDir = repository.toURI().toString();
|
||||
//workaround for spaces non converted by PathUtils in wagon
|
||||
//TODO: remove it when PathUtils will be fixed
|
||||
if ( repoDir.indexOf( "%20" ) >= 0 )
|
||||
{
|
||||
repoDir = StringUtils.replace( repoDir, "%20", " " );
|
||||
}
|
||||
|
||||
return repoFactory.createArtifactRepository( id, repoDir, repositoryLayout, null, null );
|
||||
}
|
||||
|
||||
private static String getUpdatePolicy( String policy, int interval )
|
||||
{
|
||||
return "interval".equals( policy ) ? policy + ":" + interval : policy;
|
||||
}
|
||||
|
||||
private static boolean isEnabled( String policy )
|
||||
{
|
||||
return !"disabled".equals( policy );
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.BaseFile;
|
||||
import org.apache.maven.archiva.reporting.database.ArtifactResultsDatabase;
|
||||
import org.apache.maven.archiva.reporting.group.ReportGroup;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* ArtifactHealthConsumer
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.common.consumers.Consumer"
|
||||
* role-hint="artifact-health"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ArtifactHealthConsumer
|
||||
extends GenericArtifactConsumer
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArtifactResultsDatabase database;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="health"
|
||||
*/
|
||||
private ReportGroup health;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private MavenProjectBuilder projectBuilder;
|
||||
|
||||
public void processArtifact( Artifact artifact, BaseFile file )
|
||||
{
|
||||
Model model = null;
|
||||
try
|
||||
{
|
||||
Artifact pomArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact
|
||||
.getArtifactId(), artifact.getVersion() );
|
||||
MavenProject project = projectBuilder.buildFromRepository( pomArtifact, Collections.EMPTY_LIST, repository );
|
||||
|
||||
model = project.getModel();
|
||||
}
|
||||
catch ( InvalidArtifactRTException e )
|
||||
{
|
||||
database.addWarning( artifact, "health", "invalid", "Invalid artifact [" + artifact + "] : " + e );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
database.addWarning( artifact, "health", "project-build", "Error reading project model: " + e );
|
||||
}
|
||||
|
||||
database.remove( artifact );
|
||||
health.processArtifact( artifact, model );
|
||||
}
|
||||
|
||||
public void processFileProblem( BaseFile path, String message )
|
||||
{
|
||||
/* do nothing here (yet) */
|
||||
// TODO: store build failure into database?
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "Artifact Health Consumer";
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.BaseFile;
|
||||
import org.apache.maven.archiva.reporting.database.MetadataResultsDatabase;
|
||||
import org.apache.maven.archiva.reporting.group.ReportGroup;
|
||||
import org.apache.maven.archiva.reporting.model.MetadataResults;
|
||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||
|
||||
/**
|
||||
* RepositoryMetadataHealthConsumer
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.common.consumers.Consumer"
|
||||
* role-hint="metadata-health"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class RepositoryMetadataHealthConsumer
|
||||
extends GenericRepositoryMetadataConsumer
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private MetadataResultsDatabase database;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="health"
|
||||
*/
|
||||
private ReportGroup health;
|
||||
|
||||
public void processRepositoryMetadata( RepositoryMetadata metadata, BaseFile file )
|
||||
{
|
||||
MetadataResults results = database.getMetadataResults( metadata );
|
||||
database.clearResults( results );
|
||||
|
||||
health.processMetadata( metadata, repository );
|
||||
}
|
||||
|
||||
public void processFileProblem( BaseFile path, String message )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return "RepositoryMetadata Health Consumer";
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package org.apache.maven.archiva.repositories;
|
||||
|
||||
/*
|
||||
* 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.artifact.managed.ManagedArtifact;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ActiveManagedRepositories
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ActiveManagedRepositories
|
||||
{
|
||||
String ROLE = ActiveManagedRepositories.class.getName();
|
||||
|
||||
/**
|
||||
* Obtain the ArtifactRepository for the specified Repository ID.
|
||||
*
|
||||
* @param id the ID of the repository.
|
||||
* @return the ArtifactRepository associated with the provided ID, or null if none found.
|
||||
*/
|
||||
public ArtifactRepository getArtifactRepository( String id );
|
||||
|
||||
/**
|
||||
* Get the List of active managed repositories as a List of {@link ArtifactRepository} objects.
|
||||
*
|
||||
* @return the list of ArtifactRepository objects.
|
||||
*/
|
||||
public List /*<ArtifactRepository>*/getAllArtifactRepositories();
|
||||
|
||||
RepositoryConfiguration getRepositoryConfiguration( String id );
|
||||
|
||||
/**
|
||||
* Providing only a groupId, artifactId, and version, return the MavenProject that
|
||||
* is found, in any managed repository.
|
||||
*
|
||||
* @param groupId the groupId to search for
|
||||
* @param artifactId the artifactId to search for
|
||||
* @param version the version to search for
|
||||
* @return the MavenProject from the provided parameters.
|
||||
* @throws ProjectBuildingException if there was a problem building the maven project object.
|
||||
*/
|
||||
MavenProject findProject( String groupId, String artifactId, String version )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
ManagedArtifact findArtifact( String groupId, String artifactId, String version )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
ManagedArtifact findArtifact( String groupId, String artifactId, String version, String type );
|
||||
|
||||
ManagedArtifact findArtifact( Artifact artifact );
|
||||
|
||||
/**
|
||||
* Obtain the last data refresh timestamp for all Managed Repositories.
|
||||
*
|
||||
* @return the last data refresh timestamp.
|
||||
*/
|
||||
long getLastDataRefreshTime();
|
||||
|
||||
/**
|
||||
* Tests to see if there needs to be a data refresh performed.
|
||||
*
|
||||
* The only valid scenario is if 1 or more repositories have not had their data refreshed ever.
|
||||
*
|
||||
* @return true if there needs to be a data refresh.
|
||||
*/
|
||||
boolean needsDataRefresh();
|
||||
}
|
|
@ -1,352 +0,0 @@
|
|||
package org.apache.maven.archiva.repositories;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.common.artifact.managed.ManagedArtifact;
|
||||
import org.apache.maven.archiva.common.artifact.managed.ManagedArtifactTypes;
|
||||
import org.apache.maven.archiva.common.artifact.managed.ManagedEjbArtifact;
|
||||
import org.apache.maven.archiva.common.artifact.managed.ManagedJavaArtifact;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.discoverer.DiscovererStatistics;
|
||||
import org.apache.maven.archiva.scheduler.executors.DataRefreshExecutor;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.cache.Cache;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
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 java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DefaultActiveManagedRepositories
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.repositories.ActiveManagedRepositories"
|
||||
*/
|
||||
public class DefaultActiveManagedRepositories
|
||||
extends AbstractLogEnabled
|
||||
implements ActiveManagedRepositories, Initializable, RegistryListener
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement role-hint="artifactCache"
|
||||
*/
|
||||
private Cache artifactCache;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private MavenProjectBuilder projectBuilder;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="projectCache"
|
||||
*/
|
||||
private Cache projectCache;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ConfiguredRepositoryFactory repositoryFactory;
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
private ArtifactRepository localRepository;
|
||||
|
||||
private List repositories;
|
||||
|
||||
public Artifact createRelatedArtifact( Artifact artifact, String classifier, String type )
|
||||
{
|
||||
String groupId = artifact.getGroupId();
|
||||
String artifactId = artifact.getArtifactId();
|
||||
String version = artifact.getVersion();
|
||||
String reltype = StringUtils.defaultIfEmpty( type, artifact.getType() );
|
||||
return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, reltype, classifier );
|
||||
}
|
||||
|
||||
public ManagedArtifact findArtifact( Artifact artifact )
|
||||
{
|
||||
ManagedArtifact managedArtifact = (ManagedArtifact) artifactCache.get( toKey( artifact ) );
|
||||
|
||||
if ( managedArtifact != null )
|
||||
{
|
||||
return managedArtifact;
|
||||
}
|
||||
|
||||
boolean snapshot = artifact.isSnapshot();
|
||||
|
||||
for ( Iterator i = repositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||
if ( snapshot && !repository.getSnapshots().isEnabled() )
|
||||
{
|
||||
// skip repo.
|
||||
continue;
|
||||
}
|
||||
|
||||
String path = repository.pathOf( artifact );
|
||||
File f = new File( repository.getBasedir(), path );
|
||||
if ( f.exists() )
|
||||
{
|
||||
// Found it.
|
||||
managedArtifact = createManagedArtifact( repository, artifact, f );
|
||||
|
||||
artifactCache.put( toKey( artifact ), managedArtifact );
|
||||
|
||||
return managedArtifact;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ManagedArtifact findArtifact( String groupId, String artifactId, String version )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = findProject( groupId, artifactId, version );
|
||||
Model model = project.getModel();
|
||||
|
||||
return findArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() );
|
||||
}
|
||||
|
||||
public ManagedArtifact findArtifact( String groupId, String artifactId, String version, String type )
|
||||
{
|
||||
Artifact artifact = artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
|
||||
return findArtifact( artifact );
|
||||
}
|
||||
|
||||
public MavenProject findProject( String groupId, String artifactId, String version )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = (MavenProject) projectCache.get( toKey( groupId, artifactId, version ) );
|
||||
|
||||
if ( project != null )
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
Artifact projectArtifact = artifactFactory.createProjectArtifact( groupId, artifactId, version );
|
||||
|
||||
project = projectBuilder.buildFromRepository( projectArtifact, repositories, localRepository );
|
||||
|
||||
projectCache.put( toKey( groupId, artifactId, version ), project );
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
public ArtifactRepository getArtifactRepository( String id )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = getRepositoryConfiguration( id );
|
||||
if ( repoConfig == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return repositoryFactory.createRepository( repoConfig );
|
||||
}
|
||||
|
||||
public List getAllArtifactRepositories()
|
||||
{
|
||||
return repositoryFactory.createRepositories( configuration );
|
||||
}
|
||||
|
||||
public RepositoryConfiguration getRepositoryConfiguration( String id )
|
||||
{
|
||||
return this.configuration.getRepositoryById( id );
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
archivaConfiguration.addChangeListener( this );
|
||||
configureSelf( config );
|
||||
}
|
||||
|
||||
private String toKey( Artifact artifact )
|
||||
{
|
||||
if ( artifact == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return toKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
|
||||
}
|
||||
|
||||
private String toKey( String groupId, String artifactId, String version )
|
||||
{
|
||||
return groupId + ":" + artifactId + ":" + version;
|
||||
}
|
||||
|
||||
private void configureSelf( Configuration config )
|
||||
{
|
||||
this.configuration = config;
|
||||
this.artifactCache.clear();
|
||||
this.projectCache.clear();
|
||||
|
||||
repositories = repositoryFactory.createRepositories( this.configuration );
|
||||
localRepository = repositoryFactory.createLocalRepository( this.configuration );
|
||||
|
||||
}
|
||||
|
||||
private ManagedArtifact createManagedArtifact( ArtifactRepository repository, Artifact artifact, File f )
|
||||
{
|
||||
artifact.isSnapshot();
|
||||
String path = repository.pathOf( artifact );
|
||||
|
||||
switch ( ManagedArtifactTypes.whichType( artifact.getType() ) )
|
||||
{
|
||||
case ManagedArtifactTypes.EJB:
|
||||
ManagedEjbArtifact managedEjbArtifact = new ManagedEjbArtifact( repository.getId(), artifact, path );
|
||||
|
||||
managedEjbArtifact.setJavadocPath( pathToRelatedArtifact( repository, artifact, "javadoc", "jar" ) );
|
||||
managedEjbArtifact.setSourcesPath( pathToRelatedArtifact( repository, artifact, "sources", "jar" ) );
|
||||
managedEjbArtifact.setClientPath( pathToRelatedArtifact( repository, artifact, "client", "jar" ) );
|
||||
|
||||
return managedEjbArtifact;
|
||||
|
||||
case ManagedArtifactTypes.JAVA:
|
||||
ManagedJavaArtifact managedJavaArtifact = new ManagedJavaArtifact( repository.getId(), artifact, path );
|
||||
|
||||
managedJavaArtifact.setJavadocPath( pathToRelatedArtifact( repository, artifact, "javadoc", "jar" ) );
|
||||
managedJavaArtifact.setSourcesPath( pathToRelatedArtifact( repository, artifact, "sources", "jar" ) );
|
||||
|
||||
return managedJavaArtifact;
|
||||
|
||||
case ManagedArtifactTypes.GENERIC:
|
||||
default:
|
||||
return new ManagedArtifact( repository.getId(), artifact, path );
|
||||
}
|
||||
}
|
||||
|
||||
private String pathToRelatedArtifact( ArtifactRepository repository, Artifact artifact, String classifier,
|
||||
String type )
|
||||
{
|
||||
Artifact relatedArtifact = createRelatedArtifact( artifact, classifier, type );
|
||||
|
||||
relatedArtifact.isSnapshot();
|
||||
String path = repository.pathOf( relatedArtifact );
|
||||
|
||||
File relatedFile = new File( repository.getBasedir(), path );
|
||||
if ( !relatedFile.exists() )
|
||||
{
|
||||
// Return null to set the ManagedArtifact related path to empty.
|
||||
return null;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( propertyName.startsWith( "repositories" ) || propertyName.startsWith( "localRepository" ) )
|
||||
{
|
||||
getLogger().debug(
|
||||
"Triggering managed repository configuration change with " + propertyName + " set to "
|
||||
+ propertyValue );
|
||||
configureSelf( archivaConfiguration.getConfiguration() );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().debug( "Not triggering managed repository configuration change with " + propertyName );
|
||||
}
|
||||
}
|
||||
|
||||
public long getLastDataRefreshTime()
|
||||
{
|
||||
long lastDataRefreshTime = 0;
|
||||
|
||||
for ( Iterator i = getAllArtifactRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||
|
||||
DiscovererStatistics stats = new DiscovererStatistics( repository );
|
||||
try
|
||||
{
|
||||
stats.load( DataRefreshExecutor.DATAREFRESH_FILE );
|
||||
if ( stats.getTimestampFinished() > lastDataRefreshTime )
|
||||
{
|
||||
lastDataRefreshTime = stats.getTimestampFinished();
|
||||
}
|
||||
}
|
||||
catch ( FileNotFoundException e)
|
||||
{
|
||||
getLogger().info(
|
||||
"No previous datarefresh timestamp available, as "
|
||||
+ DataRefreshExecutor.DATAREFRESH_FILE + " has never been generated." );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
getLogger().warn(
|
||||
"Unable to load " + DataRefreshExecutor.DATAREFRESH_FILE
|
||||
+ " to determine last refresh timestamp: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
return lastDataRefreshTime;
|
||||
}
|
||||
|
||||
public boolean needsDataRefresh()
|
||||
{
|
||||
for ( Iterator i = getAllArtifactRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||
|
||||
DiscovererStatistics stats = new DiscovererStatistics( repository );
|
||||
if ( stats.getTimestampFinished() <= 0 )
|
||||
{
|
||||
// Found a repository that has NEVER had it's data walked.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package org.apache.maven.archiva.repositories;
|
||||
|
||||
/*
|
||||
* 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.artifact.managed.ManagedArtifact;
|
||||
import org.apache.maven.archiva.common.artifact.managed.ManagedEjbArtifact;
|
||||
import org.apache.maven.archiva.common.artifact.managed.ManagedJavaArtifact;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
/**
|
||||
* DefaultActiveManagedRepositoriesTest
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultActiveManagedRepositoriesTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
private ActiveManagedRepositories managedRepos;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
managedRepos = (ActiveManagedRepositories) lookup( ActiveManagedRepositories.ROLE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a simple java find artifact with extras (sources / javadoc).
|
||||
*/
|
||||
public void testFindArtifactJavaWithExtras()
|
||||
{
|
||||
ManagedArtifact artifact = managedRepos.findArtifact( "geronimo", "daytrader-wsappclient", "1.1", "jar" );
|
||||
assertNotNull( artifact );
|
||||
|
||||
if ( !( artifact instanceof ManagedJavaArtifact ) )
|
||||
{
|
||||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" +
|
||||
artifact.getClass().getName() + ">." );
|
||||
}
|
||||
|
||||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact;
|
||||
|
||||
assertEquals( "test", javaArtifact.getRepositoryId() );
|
||||
|
||||
String pathPrefix = "geronimo/daytrader-wsappclient/1.1";
|
||||
String pathArtifactVersion = "daytrader-wsappclient-1.1";
|
||||
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".jar", javaArtifact.getPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", javaArtifact.getJavadocPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-sources.jar", javaArtifact.getSourcesPath() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a simple java find artifact with no extras.
|
||||
*/
|
||||
public void testFindArtifactJavaSimple()
|
||||
{
|
||||
ManagedArtifact artifact = managedRepos.findArtifact( "geronimo", "daytrader-streamer", "1.1", "jar" );
|
||||
assertNotNull( artifact );
|
||||
|
||||
if ( !( artifact instanceof ManagedJavaArtifact ) )
|
||||
{
|
||||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" +
|
||||
artifact.getClass().getName() + ">." );
|
||||
}
|
||||
|
||||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact;
|
||||
|
||||
assertEquals( "test", javaArtifact.getRepositoryId() );
|
||||
|
||||
String pathPrefix = "geronimo/daytrader-streamer/1.1";
|
||||
String pathArtifactVersion = "daytrader-streamer-1.1";
|
||||
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".jar", javaArtifact.getPath() );
|
||||
assertNull( "should have no javadoc jar.", javaArtifact.getJavadocPath() );
|
||||
assertNull( "should have no sources jar.", javaArtifact.getSourcesPath() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a java find of a snapshot artifact that uses a timestamp format.
|
||||
*/
|
||||
public void testFindArtifactJavaSnapshotTimestamp()
|
||||
{
|
||||
ManagedArtifact artifact = managedRepos.findArtifact( "org.apache.geronimo.daytrader", "daytrader-wsappclient",
|
||||
"2.0-20070201.183230-5", "jar" );
|
||||
assertNotNull( artifact );
|
||||
|
||||
if ( !( artifact instanceof ManagedJavaArtifact ) )
|
||||
{
|
||||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" +
|
||||
artifact.getClass().getName() + ">." );
|
||||
}
|
||||
|
||||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact;
|
||||
|
||||
assertEquals( "test", javaArtifact.getRepositoryId() );
|
||||
|
||||
String pathPrefix = "org/apache/geronimo/daytrader/daytrader-wsappclient/2.0-SNAPSHOT";
|
||||
String pathArtifactVersion = "daytrader-wsappclient-2.0-20070201.183230-5";
|
||||
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".jar", javaArtifact.getPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", javaArtifact.getJavadocPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-sources.jar", javaArtifact.getSourcesPath() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a java find of a snapshot artifact.
|
||||
*/
|
||||
public void testFindArtifactJavaSnapshot()
|
||||
{
|
||||
ManagedArtifact artifact = managedRepos.findArtifact( "org.apache.geronimo.daytrader", "daytrader-wsappclient",
|
||||
"2.0-SNAPSHOT", "jar" );
|
||||
assertNotNull( artifact );
|
||||
|
||||
if ( !( artifact instanceof ManagedJavaArtifact ) )
|
||||
{
|
||||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" +
|
||||
artifact.getClass().getName() + ">." );
|
||||
}
|
||||
|
||||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact;
|
||||
|
||||
assertEquals( "test", javaArtifact.getRepositoryId() );
|
||||
|
||||
String pathPrefix = "org/apache/geronimo/daytrader/daytrader-wsappclient/2.0-SNAPSHOT";
|
||||
String pathArtifactVersion = "daytrader-wsappclient-2.0-SNAPSHOT";
|
||||
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".jar", javaArtifact.getPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", javaArtifact.getJavadocPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-sources.jar", javaArtifact.getSourcesPath() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a ejb find of a snapshot artifact that also has a client jar available.
|
||||
*/
|
||||
public void testFindArtifactEjbSnapshot()
|
||||
{
|
||||
ManagedArtifact artifact =
|
||||
managedRepos.findArtifact( "org.apache.geronimo.daytrader", "daytrader-ejb", "2.0-SNAPSHOT", "ejb" );
|
||||
assertNotNull( artifact );
|
||||
|
||||
if ( !( artifact instanceof ManagedEjbArtifact ) )
|
||||
{
|
||||
fail( "Expected artifact to be type <" + ManagedEjbArtifact.class.getName() + "> but was actually <" +
|
||||
artifact.getClass().getName() + ">." );
|
||||
}
|
||||
|
||||
ManagedEjbArtifact ejbArtifact = (ManagedEjbArtifact) artifact;
|
||||
|
||||
assertEquals( "test", ejbArtifact.getRepositoryId() );
|
||||
|
||||
String pathPrefix = "org/apache/geronimo/daytrader/daytrader-ejb/2.0-SNAPSHOT";
|
||||
String pathArtifactVersion = "daytrader-ejb-2.0-SNAPSHOT";
|
||||
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".jar", ejbArtifact.getPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-client.jar", ejbArtifact.getClientPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", ejbArtifact.getJavadocPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-sources.jar", ejbArtifact.getSourcesPath() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a simple java find artifact with no extras.
|
||||
*/
|
||||
public void testFindArtifactWar()
|
||||
{
|
||||
ManagedArtifact artifact = managedRepos.findArtifact( "geronimo", "daytrader-web", "1.1", "war" );
|
||||
assertNotNull( artifact );
|
||||
|
||||
if ( !( artifact instanceof ManagedJavaArtifact ) )
|
||||
{
|
||||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" +
|
||||
artifact.getClass().getName() + ">." );
|
||||
}
|
||||
|
||||
ManagedJavaArtifact warArtifact = (ManagedJavaArtifact) artifact;
|
||||
|
||||
assertEquals( "test", warArtifact.getRepositoryId() );
|
||||
|
||||
String pathPrefix = "geronimo/daytrader-web/1.1";
|
||||
String pathArtifactVersion = "daytrader-web-1.1";
|
||||
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".war", warArtifact.getPath() );
|
||||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", warArtifact.getJavadocPath() );
|
||||
assertNull( "should have no sources jar.", warArtifact.getSourcesPath() );
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@
|
|||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-api</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact-manager</artifactId>
|
||||
|
@ -47,6 +48,7 @@
|
|||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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.artifact.factory.ArtifactFactory;
|
||||
|
||||
/**
|
||||
* AbstractLayoutArtifactBuilder
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractLayoutArtifactBuilder
|
||||
implements LayoutArtifactBuilder
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
protected ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* Constructor used by plexus
|
||||
*/
|
||||
public AbstractLayoutArtifactBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used by manual process.
|
||||
*
|
||||
* @param artifactFactory the artifact factory to use.
|
||||
*/
|
||||
public AbstractLayoutArtifactBuilder( ArtifactFactory artifactFactory )
|
||||
{
|
||||
this.artifactFactory = artifactFactory;
|
||||
}
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* DefaultLayoutArtifactBuilder - artifact builder for default layout repositories.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder"
|
||||
* role-hint="default"
|
||||
*/
|
||||
public class DefaultLayoutArtifactBuilder
|
||||
extends AbstractLayoutArtifactBuilder
|
||||
implements LayoutArtifactBuilder
|
||||
{
|
||||
public DefaultLayoutArtifactBuilder()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DefaultLayoutArtifactBuilder( ArtifactFactory artifactFactory )
|
||||
{
|
||||
super( artifactFactory );
|
||||
}
|
||||
|
||||
public Artifact build( String pathToArtifact )
|
||||
throws BuilderException
|
||||
{
|
||||
if( artifactFactory == null )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to build artifact with a null artifactFactory." );
|
||||
}
|
||||
|
||||
List pathParts = new ArrayList();
|
||||
StringTokenizer st = new StringTokenizer( pathToArtifact, "/\\" );
|
||||
while ( st.hasMoreTokens() )
|
||||
{
|
||||
pathParts.add( st.nextToken() );
|
||||
}
|
||||
|
||||
Collections.reverse( pathParts );
|
||||
|
||||
Artifact artifact;
|
||||
if ( pathParts.size() >= 4 )
|
||||
{
|
||||
// maven 2.x path
|
||||
|
||||
// the actual artifact filename.
|
||||
String filename = (String) pathParts.remove( 0 );
|
||||
|
||||
// the next one is the version.
|
||||
String version = (String) pathParts.remove( 0 );
|
||||
|
||||
// the next one is the artifactId.
|
||||
String artifactId = (String) pathParts.remove( 0 );
|
||||
|
||||
// the remaining are the groupId.
|
||||
Collections.reverse( pathParts );
|
||||
String groupId = StringUtils.join( pathParts.iterator(), "." );
|
||||
|
||||
String remainingFilename = filename;
|
||||
if ( remainingFilename.startsWith( artifactId + "-" ) )
|
||||
{
|
||||
remainingFilename = remainingFilename.substring( artifactId.length() + 1 );
|
||||
|
||||
String classifier = null;
|
||||
|
||||
// TODO: use artifact handler, share with legacy discoverer
|
||||
String type;
|
||||
if ( remainingFilename.endsWith( ".tar.gz" ) )
|
||||
{
|
||||
type = "distribution-tgz";
|
||||
remainingFilename = remainingFilename
|
||||
.substring( 0, remainingFilename.length() - ".tar.gz".length() );
|
||||
}
|
||||
else if ( remainingFilename.endsWith( ".zip" ) )
|
||||
{
|
||||
type = "distribution-zip";
|
||||
remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - ".zip".length() );
|
||||
}
|
||||
else if ( remainingFilename.endsWith( "-test-sources.jar" ) )
|
||||
{
|
||||
type = "java-source";
|
||||
classifier = "test-sources";
|
||||
remainingFilename = remainingFilename.substring( 0, remainingFilename.length()
|
||||
- "-test-sources.jar".length() );
|
||||
}
|
||||
else if ( remainingFilename.endsWith( "-sources.jar" ) )
|
||||
{
|
||||
type = "java-source";
|
||||
classifier = "sources";
|
||||
remainingFilename = remainingFilename.substring( 0, remainingFilename.length()
|
||||
- "-sources.jar".length() );
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = remainingFilename.lastIndexOf( "." );
|
||||
if ( index >= 0 )
|
||||
{
|
||||
type = remainingFilename.substring( index + 1 );
|
||||
remainingFilename = remainingFilename.substring( 0, index );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path filename does not have an extension." );
|
||||
}
|
||||
}
|
||||
|
||||
Artifact result;
|
||||
if ( classifier == null )
|
||||
{
|
||||
result = artifactFactory
|
||||
.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
|
||||
classifier );
|
||||
}
|
||||
|
||||
if ( result.isSnapshot() )
|
||||
{
|
||||
// version is *-SNAPSHOT, filename is *-yyyyMMdd.hhmmss-b
|
||||
int classifierIndex = remainingFilename.indexOf( '-', version.length() + 8 );
|
||||
if ( classifierIndex >= 0 )
|
||||
{
|
||||
classifier = remainingFilename.substring( classifierIndex + 1 );
|
||||
remainingFilename = remainingFilename.substring( 0, classifierIndex );
|
||||
result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, remainingFilename,
|
||||
type, classifier );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = artifactFactory.createArtifact( groupId, artifactId, remainingFilename,
|
||||
Artifact.SCOPE_RUNTIME, type );
|
||||
}
|
||||
|
||||
// poor encapsulation requires we do this to populate base version
|
||||
if ( !result.isSnapshot() )
|
||||
{
|
||||
throw new BuilderException( "Failed to create a snapshot artifact: " + result );
|
||||
}
|
||||
else if ( !result.getBaseVersion().equals( version ) )
|
||||
{
|
||||
throw new BuilderException(
|
||||
"Built snapshot artifact base version does not match path version: "
|
||||
+ result.getBaseVersion() + "; should have been version: "
|
||||
+ version );
|
||||
}
|
||||
else
|
||||
{
|
||||
artifact = result;
|
||||
}
|
||||
}
|
||||
else if ( !remainingFilename.startsWith( version ) )
|
||||
{
|
||||
throw new BuilderException( "Built artifact version does not match path version" );
|
||||
}
|
||||
else if ( !remainingFilename.equals( version ) )
|
||||
{
|
||||
if ( remainingFilename.charAt( version.length() ) == '-' )
|
||||
{
|
||||
classifier = remainingFilename.substring( version.length() + 1 );
|
||||
artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
|
||||
classifier );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path version does not corresspond to an artifact version" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
artifact = result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path filename does not correspond to an artifact." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path is too short to build an artifact from." );
|
||||
}
|
||||
|
||||
return artifact;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
/**
|
||||
* LayoutArtifactBuilder
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @todo this concept should really exist inside of the {@link ArtifactRepositoryLayout} object in maven itself.
|
||||
*/
|
||||
public interface LayoutArtifactBuilder
|
||||
{
|
||||
public Artifact build( String pathToArtifact ) throws BuilderException;
|
||||
}
|
|
@ -1,303 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* LegacyLayoutArtifactBuilder
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder"
|
||||
* role-hint="legacy"
|
||||
*/
|
||||
public class LegacyLayoutArtifactBuilder
|
||||
extends AbstractLayoutArtifactBuilder
|
||||
implements LayoutArtifactBuilder
|
||||
{
|
||||
public LegacyLayoutArtifactBuilder()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public LegacyLayoutArtifactBuilder( ArtifactFactory artifactFactory )
|
||||
{
|
||||
super( artifactFactory );
|
||||
}
|
||||
|
||||
public Artifact build( String pathToArtifact )
|
||||
throws BuilderException
|
||||
{
|
||||
if( artifactFactory == null )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to build legacy artifact with a null artifactFactory." );
|
||||
}
|
||||
|
||||
StringTokenizer tokens = new StringTokenizer( pathToArtifact, "/\\" );
|
||||
|
||||
Artifact result;
|
||||
|
||||
int numberOfTokens = tokens.countTokens();
|
||||
|
||||
if ( numberOfTokens == 3 )
|
||||
{
|
||||
String groupId = tokens.nextToken();
|
||||
|
||||
String type = tokens.nextToken();
|
||||
|
||||
if ( type.endsWith( "s" ) )
|
||||
{
|
||||
type = type.substring( 0, type.length() - 1 );
|
||||
|
||||
// contains artifactId, version, classifier, and extension.
|
||||
String avceGlob = tokens.nextToken();
|
||||
|
||||
//noinspection CollectionDeclaredAsConcreteClass
|
||||
LinkedList avceTokenList = new LinkedList();
|
||||
|
||||
StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" );
|
||||
while ( avceTokenizer.hasMoreTokens() )
|
||||
{
|
||||
avceTokenList.addLast( avceTokenizer.nextToken() );
|
||||
}
|
||||
|
||||
String lastAvceToken = (String) avceTokenList.removeLast();
|
||||
|
||||
// TODO: share with other discoverer, use artifact handlers instead
|
||||
if ( lastAvceToken.endsWith( ".tar.gz" ) )
|
||||
{
|
||||
type = "distribution-tgz";
|
||||
|
||||
lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".tar.gz".length() );
|
||||
|
||||
avceTokenList.addLast( lastAvceToken );
|
||||
}
|
||||
else if ( lastAvceToken.endsWith( "sources.jar" ) )
|
||||
{
|
||||
type = "java-source";
|
||||
|
||||
lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() );
|
||||
|
||||
avceTokenList.addLast( lastAvceToken );
|
||||
}
|
||||
else if ( lastAvceToken.endsWith( "javadoc.jar" ) )
|
||||
{
|
||||
type = "javadoc.jar";
|
||||
|
||||
lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() );
|
||||
|
||||
avceTokenList.addLast( lastAvceToken );
|
||||
}
|
||||
else if ( lastAvceToken.endsWith( ".zip" ) )
|
||||
{
|
||||
type = "distribution-zip";
|
||||
|
||||
lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".zip".length() );
|
||||
|
||||
avceTokenList.addLast( lastAvceToken );
|
||||
}
|
||||
else
|
||||
{
|
||||
int extPos = lastAvceToken.lastIndexOf( '.' );
|
||||
|
||||
if ( extPos > 0 )
|
||||
{
|
||||
String ext = lastAvceToken.substring( extPos + 1 );
|
||||
if ( type.equals( ext ) || "plugin".equals( type ) )
|
||||
{
|
||||
lastAvceToken = lastAvceToken.substring( 0, extPos );
|
||||
|
||||
avceTokenList.addLast( lastAvceToken );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path type does not match the extension" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path filename does not have an extension" );
|
||||
}
|
||||
}
|
||||
|
||||
// let's discover the version, and whatever's leftover will be either
|
||||
// a classifier, or part of the artifactId, depending on position.
|
||||
// Since version is at the end, we have to move in from the back.
|
||||
Collections.reverse( avceTokenList );
|
||||
|
||||
// TODO: this is obscene - surely a better way?
|
||||
String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|"
|
||||
+ "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|"
|
||||
+ "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|"
|
||||
+ "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|"
|
||||
+ "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|"
|
||||
+ "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|"
|
||||
+ "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)";
|
||||
|
||||
StringBuffer classifierBuffer = new StringBuffer();
|
||||
StringBuffer versionBuffer = new StringBuffer();
|
||||
|
||||
boolean firstVersionTokenEncountered = false;
|
||||
boolean firstToken = true;
|
||||
|
||||
int tokensIterated = 0;
|
||||
for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
|
||||
{
|
||||
String token = (String) it.next();
|
||||
|
||||
boolean tokenIsVersionPart = token.matches( validVersionParts );
|
||||
|
||||
StringBuffer bufferToUpdate;
|
||||
|
||||
// NOTE: logic in code is reversed, since we're peeling off the back
|
||||
// Any token after the last versionPart will be in the classifier.
|
||||
// Any token UP TO first non-versionPart is part of the version.
|
||||
if ( !tokenIsVersionPart )
|
||||
{
|
||||
if ( firstVersionTokenEncountered )
|
||||
{
|
||||
//noinspection BreakStatement
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferToUpdate = classifierBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
firstVersionTokenEncountered = true;
|
||||
|
||||
bufferToUpdate = versionBuffer;
|
||||
}
|
||||
|
||||
if ( firstToken )
|
||||
{
|
||||
firstToken = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferToUpdate.insert( 0, '-' );
|
||||
}
|
||||
|
||||
bufferToUpdate.insert( 0, token );
|
||||
|
||||
tokensIterated++;
|
||||
}
|
||||
|
||||
// Now, restore the proper ordering so we can build the artifactId.
|
||||
Collections.reverse( avceTokenList );
|
||||
|
||||
// if we didn't find a version, then punt. Use the last token
|
||||
// as the version, and set the classifier empty.
|
||||
if ( versionBuffer.length() < 1 )
|
||||
{
|
||||
if ( avceTokenList.size() > 1 )
|
||||
{
|
||||
int lastIdx = avceTokenList.size() - 1;
|
||||
|
||||
versionBuffer.append( avceTokenList.get( lastIdx ) );
|
||||
avceTokenList.remove( lastIdx );
|
||||
}
|
||||
|
||||
classifierBuffer.setLength( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if everything is kosher, then pop off all the classifier and
|
||||
// version tokens, leaving the naked artifact id in the list.
|
||||
avceTokenList = new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - tokensIterated ) );
|
||||
}
|
||||
|
||||
StringBuffer artifactIdBuffer = new StringBuffer();
|
||||
|
||||
firstToken = true;
|
||||
for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
|
||||
{
|
||||
String token = (String) it.next();
|
||||
|
||||
if ( firstToken )
|
||||
{
|
||||
firstToken = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
artifactIdBuffer.append( '-' );
|
||||
}
|
||||
|
||||
artifactIdBuffer.append( token );
|
||||
}
|
||||
|
||||
String artifactId = artifactIdBuffer.toString();
|
||||
|
||||
if ( artifactId.length() > 0 )
|
||||
{
|
||||
int lastVersionCharIdx = versionBuffer.length() - 1;
|
||||
if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' )
|
||||
{
|
||||
versionBuffer.setLength( lastVersionCharIdx );
|
||||
}
|
||||
|
||||
String version = versionBuffer.toString();
|
||||
|
||||
if ( version.length() > 0 )
|
||||
{
|
||||
if ( classifierBuffer.length() > 0 )
|
||||
{
|
||||
result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type,
|
||||
classifierBuffer.toString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = artifactFactory.createArtifact( groupId, artifactId, version,
|
||||
Artifact.SCOPE_RUNTIME, type );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path filename version is empty" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path filename artifactId is empty" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path artifact type does not corresspond to an artifact type" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuilderException( "Path does not match a legacy repository path for an artifact" );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.managed;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ManagedArtifact
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManagedArtifact
|
||||
{
|
||||
private String repositoryId;
|
||||
|
||||
private Artifact artifact;
|
||||
|
||||
private String path;
|
||||
|
||||
protected Map attached;
|
||||
|
||||
public ManagedArtifact( String repoId, Artifact artifact, String path )
|
||||
{
|
||||
super();
|
||||
this.repositoryId = repoId;
|
||||
this.artifact = artifact;
|
||||
this.path = path;
|
||||
this.attached = new HashMap();
|
||||
}
|
||||
|
||||
public Artifact getArtifact()
|
||||
{
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getRepositoryId()
|
||||
{
|
||||
return repositoryId;
|
||||
}
|
||||
|
||||
public Map getAttached()
|
||||
{
|
||||
return attached;
|
||||
}
|
||||
|
||||
public void setAttached( Map attached )
|
||||
{
|
||||
this.attached = attached;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.managed;
|
||||
|
||||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ManagedArtifactTypes - provides place to test an unknown artifact type.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManagedArtifactTypes
|
||||
{
|
||||
public static final int GENERIC = 0;
|
||||
|
||||
public static final int JAVA = 1;
|
||||
|
||||
public static final int EJB = 2;
|
||||
|
||||
private static List javaArtifacts;
|
||||
|
||||
private static List ejbArtifacts;
|
||||
|
||||
static
|
||||
{
|
||||
javaArtifacts = new ArrayList();
|
||||
javaArtifacts.add( "jar" );
|
||||
javaArtifacts.add( "war" );
|
||||
javaArtifacts.add( "sar" );
|
||||
javaArtifacts.add( "rar" );
|
||||
javaArtifacts.add( "ear" );
|
||||
|
||||
ejbArtifacts = new ArrayList();
|
||||
ejbArtifacts.add( "ejb" );
|
||||
ejbArtifacts.add( "ejb-client" );
|
||||
}
|
||||
|
||||
public static int whichType( String type )
|
||||
{
|
||||
if ( StringUtils.isBlank( type ) )
|
||||
{
|
||||
// TODO: is an empty type even possible?
|
||||
return GENERIC;
|
||||
}
|
||||
|
||||
type = type.toLowerCase();
|
||||
|
||||
if ( ejbArtifacts.contains( type ) )
|
||||
{
|
||||
return EJB;
|
||||
}
|
||||
|
||||
if ( javaArtifacts.contains( type ) )
|
||||
{
|
||||
return JAVA;
|
||||
}
|
||||
|
||||
return GENERIC;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.managed;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
|
||||
/**
|
||||
* ManagedEjbArtifact - adds the ability to reference the ejb-client jar too.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManagedEjbArtifact
|
||||
extends ManagedJavaArtifact
|
||||
{
|
||||
public static final String CLIENT = "client";
|
||||
|
||||
public ManagedEjbArtifact( String repoId, Artifact artifact, String path )
|
||||
{
|
||||
super( repoId, artifact, path );
|
||||
}
|
||||
|
||||
public String getClientPath()
|
||||
{
|
||||
return (String) super.attached.get( CLIENT );
|
||||
}
|
||||
|
||||
public void setClientPath( String clientPath )
|
||||
{
|
||||
super.attached.put( CLIENT, clientPath );
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.managed;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
|
||||
/**
|
||||
* ManagedJavaArtifact - a ManagedArtifact with optional javadoc and source
|
||||
* reference jars.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManagedJavaArtifact
|
||||
extends ManagedArtifact
|
||||
{
|
||||
public static final String JAVADOC = "javadoc";
|
||||
|
||||
public static final String SOURCES = "sources";
|
||||
|
||||
public ManagedJavaArtifact( String repoId, Artifact artifact, String path )
|
||||
{
|
||||
super( repoId, artifact, path );
|
||||
}
|
||||
|
||||
public String getJavadocPath()
|
||||
{
|
||||
return (String) super.attached.get( JAVADOC );
|
||||
}
|
||||
|
||||
public void setJavadocPath( String javadocPath )
|
||||
{
|
||||
super.attached.put( JAVADOC, javadocPath );
|
||||
}
|
||||
|
||||
public String getSourcesPath()
|
||||
{
|
||||
return (String) super.attached.get( SOURCES );
|
||||
}
|
||||
|
||||
public void setSourcesPath( String sourcesPath )
|
||||
{
|
||||
super.attached.put( SOURCES, sourcesPath );
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.archiva.repository.version;
|
||||
package org.apache.maven.archiva.common.utils;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -1,146 +0,0 @@
|
|||
package org.apache.maven.archiva.common;
|
||||
|
||||
/*
|
||||
* 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.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AbstractArchivaCommonTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractArchivaCommonTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
protected ArtifactRepository createRepository( File basedir, String layout )
|
||||
throws Exception
|
||||
{
|
||||
ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
|
||||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, layout );
|
||||
|
||||
return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, repoLayout, null, null );
|
||||
}
|
||||
|
||||
public List getLegacyLayoutArtifactPaths()
|
||||
{
|
||||
List files = new ArrayList();
|
||||
|
||||
files.add( "invalid/jars/1.0/invalid-1.0.jar" );
|
||||
files.add( "invalid/jars/invalid-1.0.rar" );
|
||||
files.add( "invalid/jars/invalid.jar" );
|
||||
files.add( "invalid/invalid-1.0.jar" );
|
||||
files.add( "javax.sql/jars/jdbc-2.0.jar" );
|
||||
files.add( "org.apache.maven/jars/some-ejb-1.0-client.jar" );
|
||||
files.add( "org.apache.maven/jars/testing-1.0.jar" );
|
||||
files.add( "org.apache.maven/jars/testing-1.0-sources.jar" );
|
||||
files.add( "org.apache.maven/jars/testing-UNKNOWN.jar" );
|
||||
files.add( "org.apache.maven/jars/testing-1.0.zip" );
|
||||
files.add( "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar" );
|
||||
files.add( "org.apache.maven/jars/testing-1.0.tar.gz" );
|
||||
files.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" );
|
||||
files.add( "org.apache.maven.update/jars/test-updated-1.0.jar" );
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public List getDefaultLayoutArtifactPaths()
|
||||
{
|
||||
List files = new ArrayList();
|
||||
|
||||
files.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
|
||||
files.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
|
||||
files.add( "invalid/invalid/1.0/invalid-1.0b.jar" );
|
||||
files.add( "invalid/invalid/1.0/invalid-2.0.jar" );
|
||||
files.add( "invalid/invalid-1.0.jar" );
|
||||
files.add( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" );
|
||||
files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" );
|
||||
files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" );
|
||||
files.add( "org/apache/maven/A/1.0/A-1.0.war" );
|
||||
files.add( "org/apache/maven/A/1.0/A-1.0.pom" );
|
||||
files.add( "org/apache/maven/B/2.0/B-2.0.pom" );
|
||||
files.add( "org/apache/maven/B/1.0/B-1.0.pom" );
|
||||
files.add( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" );
|
||||
files.add( "org/apache/maven/C/1.0/C-1.0.war" );
|
||||
files.add( "org/apache/maven/C/1.0/C-1.0.pom" );
|
||||
files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" );
|
||||
files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar" );
|
||||
files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" );
|
||||
files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar" );
|
||||
files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" );
|
||||
files.add( "org/apache/maven/testing/1.0/testing-1.0-test-sources.jar" );
|
||||
files.add( "org/apache/maven/testing/1.0/testing-1.0.jar" );
|
||||
files.add( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" );
|
||||
files.add( "org/apache/maven/testing/1.0/testing-1.0.zip" );
|
||||
files.add( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" );
|
||||
files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" );
|
||||
files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.jar" );
|
||||
files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" );
|
||||
files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" );
|
||||
files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );
|
||||
files.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" );
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public List getDefaultLayoutMetadataPaths()
|
||||
{
|
||||
List files = new ArrayList();
|
||||
|
||||
files.add( "org/apache/maven/some-ejb/1.0/maven-metadata.xml" );
|
||||
files.add( "org/apache/maven/update/test-not-updated/maven-metadata.xml" );
|
||||
files.add( "org/apache/maven/update/test-updated/maven-metadata.xml" );
|
||||
files.add( "org/apache/maven/maven-metadata.xml" );
|
||||
files.add( "org/apache/testgroup/discovery/1.0/maven-metadata.xml" );
|
||||
files.add( "org/apache/testgroup/discovery/maven-metadata.xml" );
|
||||
files.add( "javax/sql/jdbc/2.0/maven-metadata-repository.xml" );
|
||||
files.add( "javax/sql/jdbc/maven-metadata-repository.xml" );
|
||||
files.add( "javax/sql/maven-metadata-repository.xml" );
|
||||
files.add( "javax/maven-metadata.xml" );
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public List getDefaultLayoutModelPaths()
|
||||
{
|
||||
List files = new ArrayList();
|
||||
|
||||
files.add( "org/apache/maven/A/1.0/A-1.0.pom" );
|
||||
files.add( "org/apache/maven/B/2.0/B-2.0.pom" );
|
||||
files.add( "org/apache/maven/B/1.0/B-1.0.pom" );
|
||||
files.add( "org/apache/maven/C/1.0/C-1.0.pom" );
|
||||
files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" );
|
||||
files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" );
|
||||
files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" );
|
||||
files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" );
|
||||
files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" );
|
||||
files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" );
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ public class AllTests
|
|||
{
|
||||
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.common" );
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTest( org.apache.maven.archiva.common.artifact.builder.AllTests.suite() );
|
||||
suite.addTest( org.apache.maven.archiva.common.utils.AllTests.suite() );
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.Artifact;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
/**
|
||||
* AbstractLayoutArtifactBuilderTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractLayoutArtifactBuilderTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
|
||||
protected void assertArtifact( String groupId, String artifactId, String version, String type, String classifier, Artifact artifact )
|
||||
{
|
||||
assertNotNull( "Artifact cannot be null.", artifact );
|
||||
|
||||
assertEquals( "Artifact groupId", groupId, artifact.getGroupId() );
|
||||
assertEquals( "Artifact artifactId", artifactId, artifact.getArtifactId() );
|
||||
assertEquals( "Artifact version", version, artifact.getVersion() );
|
||||
assertEquals( "Artifact type", type, artifact.getType() );
|
||||
|
||||
if ( StringUtils.isNotBlank( classifier ) )
|
||||
{
|
||||
assertEquals( "Artifact classifier", classifier, artifact.getClassifier() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DefaultLayoutArtifactBuilderTest
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultLayoutArtifactBuilderTest
|
||||
extends AbstractLayoutArtifactBuilderTestCase
|
||||
{
|
||||
LayoutArtifactBuilder builder;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "default" );
|
||||
assertNotNull( builder );
|
||||
}
|
||||
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
if ( builder != null )
|
||||
{
|
||||
release( builder );
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testPathDistributionArtifacts()
|
||||
throws BuilderException
|
||||
{
|
||||
assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz", null, builder
|
||||
.build( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ) );
|
||||
|
||||
assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip", null, builder
|
||||
.build( "org/apache/maven/testing/1.0/testing-1.0.zip" ) );
|
||||
}
|
||||
|
||||
public void testPathNormal()
|
||||
throws BuilderException
|
||||
{
|
||||
assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder
|
||||
.build( "/org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) );
|
||||
|
||||
assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder
|
||||
.build( "org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) );
|
||||
|
||||
assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, builder.build( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ) );
|
||||
|
||||
}
|
||||
|
||||
public void testPathSnapshots()
|
||||
throws BuilderException
|
||||
{
|
||||
assertArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT", "jar", null, builder
|
||||
.build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.jar" ) );
|
||||
|
||||
assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", null, builder
|
||||
.build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ) );
|
||||
}
|
||||
|
||||
public void testPathSnapshotWithClassifier()
|
||||
throws BuilderException
|
||||
{
|
||||
assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", "javadoc", builder
|
||||
.build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ) );
|
||||
}
|
||||
|
||||
public void testPathWithClassifier()
|
||||
throws BuilderException
|
||||
{
|
||||
assertArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client", builder
|
||||
.build( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ) );
|
||||
}
|
||||
|
||||
public void testPathWithJavaSourceInclusion()
|
||||
throws BuilderException
|
||||
{
|
||||
assertArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources", builder
|
||||
.build( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ) );
|
||||
}
|
||||
|
||||
public void testProblemMissingType()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid/1/invalid-1" );
|
||||
fail( "Should have detected missing type." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path filename does not have an extension.", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemNonSnapshotInSnapshotDir()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
|
||||
fail( "Non Snapshot artifact inside of an Snapshot dir is invalid." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Failed to create a snapshot artifact: invalid:invalid:jar:1.0:runtime", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemPathTooShort()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid-1.0.jar" );
|
||||
fail( "Should have detected that path is too short." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path is too short to build an artifact from.", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemTimestampSnapshotNotInSnapshotDir()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
|
||||
fail( "Timestamped Snapshot artifact not inside of an Snapshot dir is invalid." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
// TODO: Is this really the right thing to do for this kind of artifact??
|
||||
assertEquals( "Built snapshot artifact base version does not match path version: 1.0-SNAPSHOT; "
|
||||
+ "should have been version: 1.0-20050611.123456-1", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemVersionPathMismatch()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid/1.0/invalid-2.0.jar" );
|
||||
fail( "Should have detected version mismatch between path and artifact." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Built artifact version does not match path version", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemVersionPathMismatchAlt()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid/1.0/invalid-1.0b.jar" );
|
||||
fail( "Should have version mismatch between directory and artifact." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path version does not corresspond to an artifact version", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemWrongArtifactId()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" );
|
||||
fail( "Should have detected wrong artifact Id." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path filename does not correspond to an artifact.", e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
package org.apache.maven.archiva.common.artifact.builder;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
/**
|
||||
* LegacyLayoutArtifactBuilderTest
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class LegacyLayoutArtifactBuilderTest
|
||||
extends AbstractLayoutArtifactBuilderTestCase
|
||||
{
|
||||
LayoutArtifactBuilder builder;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "legacy" );
|
||||
assertNotNull( builder );
|
||||
}
|
||||
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
if ( builder != null )
|
||||
{
|
||||
release( builder );
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testPathNormal()
|
||||
throws BuilderException
|
||||
{
|
||||
Artifact artifact = builder.build( "javax.sql/jars/jdbc-2.0.jar" );
|
||||
|
||||
assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, artifact );
|
||||
}
|
||||
|
||||
public void testPathFinal()
|
||||
throws BuilderException
|
||||
{
|
||||
Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-final-20060606.jar" );
|
||||
|
||||
assertArtifact( "org.apache.maven.test", "maven-model", "1.0-final-20060606", "jar", null, artifact );
|
||||
}
|
||||
|
||||
public void testPathSnapshot()
|
||||
throws BuilderException
|
||||
{
|
||||
Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-SNAPSHOT.jar" );
|
||||
|
||||
assertArtifact( "org.apache.maven.test", "maven-model", "1.0-SNAPSHOT", "jar", null, artifact );
|
||||
}
|
||||
|
||||
public void testPathJavadoc()
|
||||
throws BuilderException
|
||||
{
|
||||
Artifact artifact = builder.build( "javax.sql/javadoc.jars/jdbc-2.0-javadoc.jar" );
|
||||
|
||||
assertArtifact( "javax.sql", "jdbc", "2.0", "javadoc.jar", "javadoc", artifact );
|
||||
}
|
||||
|
||||
public void testPathSources()
|
||||
throws BuilderException
|
||||
{
|
||||
Artifact artifact = builder.build( "javax.sql/java-sources/jdbc-2.0-sources.jar" );
|
||||
|
||||
assertArtifact( "javax.sql", "jdbc", "2.0", "java-source", "sources", artifact );
|
||||
}
|
||||
|
||||
public void testPathPlugin()
|
||||
throws BuilderException
|
||||
{
|
||||
Artifact artifact = builder.build( "maven/plugins/maven-test-plugin-1.8.jar" );
|
||||
|
||||
assertArtifact( "maven", "maven-test-plugin", "1.8", "plugin", null, artifact );
|
||||
}
|
||||
|
||||
public void testProblemNoType()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "invalid/invalid/1/invalid-1" );
|
||||
|
||||
fail( "Should have detected no type." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path does not match a legacy repository path for an artifact", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemWrongArtifactPackaging()
|
||||
throws ComponentLookupException
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "org.apache.maven.test/jars/artifactId-1.0.jar.md5" );
|
||||
|
||||
fail( "Should have detected wrong package extension." );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path type does not match the extension", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testProblemNoArtifactId()
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.build( "groupId/jars/-1.0.jar" );
|
||||
|
||||
fail( "Should have detected artifactId is missing" );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path filename artifactId is empty", e.getMessage() );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
builder.build( "groupId/jars/1.0.jar" );
|
||||
|
||||
fail( "Should have detected artifactId is missing" );
|
||||
}
|
||||
catch ( BuilderException e )
|
||||
{
|
||||
/* expected path */
|
||||
assertEquals( "Path filename artifactId is empty", e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,17 +75,80 @@
|
|||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>fileProcessors</name>
|
||||
<name>repositoryScanning</name>
|
||||
<version>1.0.0+</version>
|
||||
<association>
|
||||
<type>FileProcessor</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
<type>RepositoryScanningConfiguration</type>
|
||||
<multiplicity>1</multiplicity>
|
||||
</association>
|
||||
<description>
|
||||
The file processors setup.
|
||||
The repository scanning configuration.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
<field>
|
||||
<name>databaseScanning</name>
|
||||
<version>1.0.0+</version>
|
||||
<association>
|
||||
<type>DatabaseScanningConfiguration</type>
|
||||
<multiplicity>1</multiplicity>
|
||||
</association>
|
||||
<description>
|
||||
The database scanning configuration.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0+</version>
|
||||
<code><![CDATA[
|
||||
/**
|
||||
* Find {@link RepositoryConfiguration} with specified Id.
|
||||
*
|
||||
* @param id the id of the repository to find.
|
||||
* @return the repository configuration.
|
||||
*/
|
||||
public RepositoryConfiguration findRepositoryById( String id )
|
||||
{
|
||||
// null id = null repo config.
|
||||
if ( id == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// empty id = null repo config.
|
||||
if ( id.trim().length() <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// null repository list = null repo config.
|
||||
if ( getRepositories() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// empty repository list == null repo config.
|
||||
if ( getRepositories().isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// find the repository
|
||||
java.util.Iterator it = getRepositories().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) it.next();
|
||||
if ( id.equals( repoConfig.getId() ) )
|
||||
{
|
||||
return repoConfig;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<!--
|
||||
|
@ -161,6 +224,14 @@
|
|||
<description>True if this repository should be indexed.</description>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>indexDir</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<description>
|
||||
The directory for the indexes of this repository.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>refreshCronExpression</name>
|
||||
<version>1.0.0+</version>
|
||||
|
@ -426,28 +497,32 @@
|
|||
</class>
|
||||
|
||||
<!--
|
||||
_____ _ _ ____
|
||||
| ___(_) | ___| _ \ _ __ ___ ___ ___ ___ ___ ___ _ __
|
||||
| |_ | | |/ _ \ |_) | '__/ _ \ / __/ _ \/ __/ __|/ _ \| '__|
|
||||
| _| | | | __/ __/| | | (_) | (_| __/\__ \__ \ (_) | |
|
||||
|_| |_|_|\___|_| |_| \___/ \___\___||___/___/\___/|_|
|
||||
____ _
|
||||
/ ___| ___ __ _ _ __ _ __ (_)_ __ __ _
|
||||
\___ \ / __/ _` | '_ \| '_ \| | '_ \ / _` |
|
||||
___) | (_| (_| | | | | | | | | | | | (_| |
|
||||
|____/ \___\__,_|_| |_|_| |_|_|_| |_|\__, |
|
||||
|___/
|
||||
|
||||
-->
|
||||
<class>
|
||||
<name>FileProcessor</name>
|
||||
<name>RepositoryScanningConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<fields>
|
||||
<field>
|
||||
<name>id</name>
|
||||
<name>fileTypes</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<type>String</type>
|
||||
<association>
|
||||
<type>FileType</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>
|
||||
The ID for this file processor
|
||||
The FileTypes for the repository scanning configuration.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>patterns</name>
|
||||
<name>goodConsumers</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<association>
|
||||
|
@ -455,11 +530,11 @@
|
|||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>
|
||||
The list of patterns for this processor.
|
||||
The list of consumers for good content.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>consumers</name>
|
||||
<name>badConsumers</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<association>
|
||||
|
@ -471,6 +546,111 @@
|
|||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0+</version>
|
||||
<code><![CDATA[
|
||||
/**
|
||||
* Get a specific file type by ID.
|
||||
*
|
||||
* @param id the id of the filetype to get. (null or empty will result in null return)
|
||||
* @return the {@link FileType} or null if the id is not found.
|
||||
*/
|
||||
public FileType getFileTypeById( String id )
|
||||
{
|
||||
if ( id == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( id.trim().length() <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
java.util.List types = getFileTypes();
|
||||
if ( types == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
java.util.Iterator it = types.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
FileType filetype = (FileType) it.next();
|
||||
if ( id.equals( filetype.getId() ) )
|
||||
{
|
||||
return filetype;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
<class>
|
||||
<name>FileType</name>
|
||||
<version>1.0.0+</version>
|
||||
<description>The FileType object</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>id</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>patterns</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<association>
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>DatabaseScanningConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<description>
|
||||
The scanning configuration for unprocessed ArchivaArtifact database objects.
|
||||
</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>cronExpression</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<description>When to run the database scanning mechanism. Default is every hour on the hour.</description>
|
||||
<defaultValue>0 0 * * * ?</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>unprocessedConsumers</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<association>
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>
|
||||
The list of consumers for the unprocessed ArchivaArtifact database objects.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>processedConsumers</name>
|
||||
<version>1.0.0+</version>
|
||||
<required>true</required>
|
||||
<association>
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>
|
||||
The list of consumers for previously processed ArchivaArtifact database objects.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
</classes>
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
<indexed>false</indexed>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<proxyConnectors>
|
||||
<proxyConnector>
|
||||
<sourceRepoId>internal</sourceRepoId>
|
||||
|
@ -57,163 +58,106 @@
|
|||
<releasePolicy>never</releasePolicy>
|
||||
<failurePolicy>not-found</failurePolicy>
|
||||
<whiteListPatterns>
|
||||
<whileListPattern>javax/**</whileListPattern>
|
||||
<whiteListPattern>javax/**</whiteListPattern>
|
||||
</whiteListPatterns>
|
||||
</proxyConnector>
|
||||
</proxyConnectors>
|
||||
|
||||
<networkProxies>
|
||||
<networkProxy>
|
||||
<id>example</id>
|
||||
<protocol>http</protocol>
|
||||
<host>proxy.mycompany.com</host>
|
||||
<port>8080</port>
|
||||
<username>myself</username>
|
||||
<password>mypass</password>
|
||||
</networkProxy>
|
||||
</networkProxies>
|
||||
<fileProcessors>
|
||||
<fileProcessor>
|
||||
<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>
|
||||
<consumers>
|
||||
<consumer>artifact-to-db</consumer>
|
||||
<consumer>artifact-to-lucene</consumer>
|
||||
<consumer>artifact-create-missing-checksums</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>projects</id>
|
||||
<patterns>
|
||||
<pattern>**/*.pom</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>project-to-db</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>repository-metadata</id>
|
||||
<patterns>
|
||||
<pattern>**/maven-metadata.xml</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>repository-metadata-to-db</consumer>
|
||||
<consumer>repository-metadata-version-mismatch</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>checksums</id>
|
||||
<patterns>
|
||||
<pattern>**/*.sha1</pattern>
|
||||
<pattern>**/*.md5</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>checksum-validate</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>signatures</id>
|
||||
<patterns>
|
||||
<pattern>**/*.asc</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>signature-validate</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>archives</id>
|
||||
<patterns>
|
||||
<pattern>**/*.jar</pattern>
|
||||
<pattern>**/*.ear</pattern>
|
||||
<pattern>**/*.war</pattern>
|
||||
<pattern>**/*.car</pattern>
|
||||
<pattern>**/*.sar</pattern>
|
||||
<pattern>**/*.mar</pattern>
|
||||
<pattern>**/*.rar</pattern>
|
||||
<pattern>**/*.tar.gz</pattern>
|
||||
<pattern>**/*.tar.bz2</pattern>
|
||||
<pattern>**/*.zip</pattern>
|
||||
<pattern>**/*.nbm</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>archive-toc-to-lucene</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>bytecode</id>
|
||||
<patterns>
|
||||
<pattern>**/*.jar</pattern>
|
||||
<pattern>**/*.war</pattern>
|
||||
<pattern>**/*.car</pattern>
|
||||
<pattern>**/*.sar</pattern>
|
||||
<pattern>**/*.mar</pattern>
|
||||
<pattern>**/*.rar</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>bytecode-to-db</consumer>
|
||||
<consumer>bytecode-to-lucene</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>xmls</id>
|
||||
<patterns>
|
||||
<pattern>**/*.pom</pattern>
|
||||
<pattern>**/*.xml</pattern>
|
||||
<pattern>**/*.xsd</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>xml-to-lucene</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>text</id>
|
||||
<patterns>
|
||||
<pattern>**/*.txt</pattern>
|
||||
<pattern>**/*.TXT</pattern>
|
||||
<pattern>**/*.block</pattern>
|
||||
<pattern>**/*.config</pattern>
|
||||
</patterns>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>ignored</id>
|
||||
<patterns>
|
||||
<pattern>**/.htaccess</pattern>
|
||||
<pattern>**/KEYS</pattern>
|
||||
<pattern>**/*.rb</pattern>
|
||||
<pattern>**/*.sh</pattern>
|
||||
<pattern>**/.svn/**</pattern>
|
||||
<pattern>**/.DAV/**</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>ignored</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>auto-remove</id>
|
||||
<patterns>
|
||||
<pattern>**/*.bak</pattern>
|
||||
<pattern>**/*~</pattern>
|
||||
<pattern>**/*-</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>auto-remove</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>auto-rename</id>
|
||||
<patterns>
|
||||
<pattern>**/*.distribution-tgz</pattern>
|
||||
<pattern>**/*.distribution-zip</pattern>
|
||||
<pattern>**/*.plugin</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>auto-rename</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
</fileProcessors>
|
||||
|
||||
<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>
|
||||
<goodConsumers>
|
||||
<goodConsumer>update-db-artifact</goodConsumer>
|
||||
<goodConsumer>create-missing-checksums</goodConsumer>
|
||||
<goodConsumer>update-db-repository-metadata</goodConsumer>
|
||||
<goodConsumer>validate-checksum</goodConsumer>
|
||||
<goodConsumer>validate-signature</goodConsumer>
|
||||
<goodConsumer>index-content</goodConsumer>
|
||||
<goodConsumer>auto-remove</goodConsumer>
|
||||
<goodConsumer>auto-rename</goodConsumer>
|
||||
</goodConsumers>
|
||||
<badConsumers>
|
||||
<badConsumer>update-db-bad-content</badConsumer>
|
||||
</badConsumers>
|
||||
</repositoryScanning>
|
||||
|
||||
<databaseScanning>
|
||||
<cronExpression>0 0 * * ?</cronExpression>
|
||||
<unprocessedConsumers>
|
||||
<unprocessedConsumer>index-artifact</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-project</unprocessedConsumer>
|
||||
<unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
|
||||
<unprocessedConsumer>index-archive-toc</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
|
||||
<unprocessedConsumer>index-public-methods</unprocessedConsumer>
|
||||
</unprocessedConsumers>
|
||||
<processedConsumers>
|
||||
<processedConsumer>not-present-remove-db-artifact</processedConsumer>
|
||||
<processedConsumer>not-present-remove-db-project</processedConsumer>
|
||||
<processedConsumer>not-present-remove-indexed</processedConsumer>
|
||||
</processedConsumers>
|
||||
</databaseScanning>
|
||||
|
||||
</configuration>
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<indexed>false</indexed>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<proxyConnectors>
|
||||
<proxyConnector>
|
||||
<sourceRepoId>internal</sourceRepoId>
|
||||
|
@ -76,163 +77,106 @@
|
|||
<releasePolicy>never</releasePolicy>
|
||||
<failurePolicy>not-found</failurePolicy>
|
||||
<whiteListPatterns>
|
||||
<whileListPattern>javax/**</whileListPattern>
|
||||
<whiteListPattern>javax/**</whiteListPattern>
|
||||
</whiteListPatterns>
|
||||
</proxyConnector>
|
||||
</proxyConnectors>
|
||||
|
||||
<networkProxies>
|
||||
<networkProxy>
|
||||
<id>example</id>
|
||||
<protocol>http</protocol>
|
||||
<host>proxy.mycompany.com</host>
|
||||
<port>8080</port>
|
||||
<username>myself</username>
|
||||
<password>mypass</password>
|
||||
</networkProxy>
|
||||
</networkProxies>
|
||||
<fileProcessors>
|
||||
<fileProcessor>
|
||||
<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>
|
||||
<consumers>
|
||||
<consumer>artifact-to-db</consumer>
|
||||
<consumer>artifact-to-lucene</consumer>
|
||||
<consumer>artifact-create-missing-checksums</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>projects</id>
|
||||
<patterns>
|
||||
<pattern>**/*.pom</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>project-to-db</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>repository-metadata</id>
|
||||
<patterns>
|
||||
<pattern>**/maven-metadata.xml</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>repository-metadata-to-db</consumer>
|
||||
<consumer>repository-metadata-version-mismatch</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>checksums</id>
|
||||
<patterns>
|
||||
<pattern>**/*.sha1</pattern>
|
||||
<pattern>**/*.md5</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>checksum-validate</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>signatures</id>
|
||||
<patterns>
|
||||
<pattern>**/*.asc</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>signature-validate</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>archives</id>
|
||||
<patterns>
|
||||
<pattern>**/*.jar</pattern>
|
||||
<pattern>**/*.ear</pattern>
|
||||
<pattern>**/*.war</pattern>
|
||||
<pattern>**/*.car</pattern>
|
||||
<pattern>**/*.sar</pattern>
|
||||
<pattern>**/*.mar</pattern>
|
||||
<pattern>**/*.rar</pattern>
|
||||
<pattern>**/*.tar.gz</pattern>
|
||||
<pattern>**/*.tar.bz2</pattern>
|
||||
<pattern>**/*.zip</pattern>
|
||||
<pattern>**/*.nbm</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>archive-toc-to-lucene</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>bytecode</id>
|
||||
<patterns>
|
||||
<pattern>**/*.jar</pattern>
|
||||
<pattern>**/*.war</pattern>
|
||||
<pattern>**/*.car</pattern>
|
||||
<pattern>**/*.sar</pattern>
|
||||
<pattern>**/*.mar</pattern>
|
||||
<pattern>**/*.rar</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>bytecode-to-db</consumer>
|
||||
<consumer>bytecode-to-lucene</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>xmls</id>
|
||||
<patterns>
|
||||
<pattern>**/*.pom</pattern>
|
||||
<pattern>**/*.xml</pattern>
|
||||
<pattern>**/*.xsd</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>xml-to-lucene</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>text</id>
|
||||
<patterns>
|
||||
<pattern>**/*.txt</pattern>
|
||||
<pattern>**/*.TXT</pattern>
|
||||
<pattern>**/*.block</pattern>
|
||||
<pattern>**/*.config</pattern>
|
||||
</patterns>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>ignored</id>
|
||||
<patterns>
|
||||
<pattern>**/.htaccess</pattern>
|
||||
<pattern>**/KEYS</pattern>
|
||||
<pattern>**/*.rb</pattern>
|
||||
<pattern>**/*.sh</pattern>
|
||||
<pattern>**/.svn/**</pattern>
|
||||
<pattern>**/.DAV/**</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>ignored</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>auto-remove</id>
|
||||
<patterns>
|
||||
<pattern>**/*.bak</pattern>
|
||||
<pattern>**/*~</pattern>
|
||||
<pattern>**/*-</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>auto-remove</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
<fileProcessor>
|
||||
<id>auto-rename</id>
|
||||
<patterns>
|
||||
<pattern>**/*.distribution-tgz</pattern>
|
||||
<pattern>**/*.distribution-zip</pattern>
|
||||
<pattern>**/*.plugin</pattern>
|
||||
</patterns>
|
||||
<consumers>
|
||||
<consumer>auto-rename</consumer>
|
||||
</consumers>
|
||||
</fileProcessor>
|
||||
</fileProcessors>
|
||||
|
||||
<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>
|
||||
<goodConsumers>
|
||||
<goodConsumer>update-db-artifact</goodConsumer>
|
||||
<goodConsumer>create-missing-checksums</goodConsumer>
|
||||
<goodConsumer>update-db-repository-metadata</goodConsumer>
|
||||
<goodConsumer>validate-checksum</goodConsumer>
|
||||
<goodConsumer>validate-signature</goodConsumer>
|
||||
<goodConsumer>index-content</goodConsumer>
|
||||
<goodConsumer>auto-remove</goodConsumer>
|
||||
<goodConsumer>auto-rename</goodConsumer>
|
||||
</goodConsumers>
|
||||
<badConsumers>
|
||||
<badConsumer>update-db-bad-content</badConsumer>
|
||||
</badConsumers>
|
||||
</repositoryScanning>
|
||||
|
||||
<databaseScanning>
|
||||
<cronExpression>0 0 * * ?</cronExpression>
|
||||
<unprocessedConsumers>
|
||||
<unprocessedConsumer>index-artifact</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-project</unprocessedConsumer>
|
||||
<unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
|
||||
<unprocessedConsumer>index-archive-toc</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
|
||||
<unprocessedConsumer>index-public-methods</unprocessedConsumer>
|
||||
</unprocessedConsumers>
|
||||
<processedConsumers>
|
||||
<processedConsumer>not-present-remove-db-artifact</processedConsumer>
|
||||
<processedConsumer>not-present-remove-db-project</processedConsumer>
|
||||
<processedConsumer>not-present-remove-indexed</processedConsumer>
|
||||
</processedConsumers>
|
||||
</databaseScanning>
|
||||
|
||||
</configuration>
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Test the configuration store.
|
||||
|
@ -53,13 +52,28 @@ public class ArchivaConfigurationTest extends PlexusTestCase
|
|||
|
||||
assertEquals( "check repositories", 4, configuration.getRepositories().size() );
|
||||
assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
|
||||
assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
|
||||
assertEquals( "check file processors", 12, configuration.getFileProcessors().size() );
|
||||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
|
||||
|
||||
RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
|
||||
assertNotNull( "check repository scanning", repoScanning );
|
||||
assertEquals( "check file types", 4, repoScanning.getFileTypes().size() );
|
||||
assertEquals( "check good consumers", 8, repoScanning.getGoodConsumers().size() );
|
||||
assertEquals( "check bad consumers", 1, repoScanning.getBadConsumers().size() );
|
||||
|
||||
FileType artifactTypes = repoScanning.getFileTypeById( "artifacts" );
|
||||
assertNotNull( "check 'artifacts' file type", artifactTypes );
|
||||
assertEquals( "check 'artifacts' patterns", 13, artifactTypes.getPatterns().size() );
|
||||
|
||||
DatabaseScanningConfiguration dbScanning = configuration.getDatabaseScanning();
|
||||
assertNotNull( "check database scanning", dbScanning );
|
||||
assertEquals( "check unprocessed consumers", 6, dbScanning.getUnprocessedConsumers().size() );
|
||||
assertEquals( "check processed consumers", 3, dbScanning.getProcessedConsumers().size() );
|
||||
|
||||
RepositoryConfiguration repository =
|
||||
(RepositoryConfiguration) configuration.getRepositories().iterator().next();
|
||||
|
||||
assertEquals( "check managed repositories", "file://${appserver.home}/repositories/internal", repository.getUrl() );
|
||||
assertEquals( "check managed repositories", "file://${appserver.home}/repositories/internal",
|
||||
repository.getUrl() );
|
||||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
|
||||
assertEquals( "check managed repositories", "internal", repository.getId() );
|
||||
assertEquals( "check managed repositories", "default", repository.getLayout() );
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-model</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* AbstractMonitoredConsumer
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractMonitoredConsumer implements BaseConsumer
|
||||
{
|
||||
private Set monitors = new HashSet();
|
||||
|
||||
public void addConsumerMonitor( ConsumerMonitor monitor )
|
||||
{
|
||||
monitors.add( monitor );
|
||||
}
|
||||
|
||||
public void removeConsumerMonitor( ConsumerMonitor monitor )
|
||||
{
|
||||
monitors.remove( monitor );
|
||||
}
|
||||
|
||||
protected void triggerConsumerError( String type, String message )
|
||||
{
|
||||
for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
|
||||
{
|
||||
ConsumerMonitor monitor = (ConsumerMonitor) itmonitors.next();
|
||||
try
|
||||
{
|
||||
monitor.consumerError( this, type, message );
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
/* discard error */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void triggerConsumerWarning( String type, String message )
|
||||
{
|
||||
for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
|
||||
{
|
||||
ConsumerMonitor monitor = (ConsumerMonitor) itmonitors.next();
|
||||
try
|
||||
{
|
||||
monitor.consumerWarning( this, type, message );
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
/* discard error */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void triggerConsumerInfo( String message )
|
||||
{
|
||||
for ( Iterator itmonitors = monitors.iterator(); itmonitors.hasNext(); )
|
||||
{
|
||||
ConsumerMonitor monitor = (ConsumerMonitor) itmonitors.next();
|
||||
try
|
||||
{
|
||||
monitor.consumerInfo( this, message );
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
/* discard error */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.ArchivaArtifact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ArchivaArtifactConsumer - consumer for ArchivaArtifact objects.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ArchivaArtifactConsumer extends BaseConsumer
|
||||
{
|
||||
/**
|
||||
* Get the list of included file patterns for this consumer.
|
||||
*
|
||||
* @return the list of ({@link String}) artifact types to process.
|
||||
*/
|
||||
public List getIncludedTypes();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event that triggers at the beginning of a scan.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
|
||||
* generally start tracking the scan as a whole.
|
||||
* </p>
|
||||
*/
|
||||
public void beginScan();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event indicating an {@link ArchivaArtifact} is to be processed by this consumer.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: The consumer does not need to process the artifact immediately, can can opt to queue and/or track
|
||||
* the artifact to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()}
|
||||
* event.
|
||||
* </p>
|
||||
*
|
||||
* @param file the file to process.
|
||||
* @throws ConsumerException if there was a problem processing this file.
|
||||
*/
|
||||
public void processArchivaArtifact( ArchivaArtifact artifact ) throws ConsumerException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event that triggers on the completion of a scan.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: If the consumer opted to batch up processing requests in the
|
||||
* {@link #processArchivaArtifact(ArchivaArtifact)} event this would be the last opportunity to drain
|
||||
* any processing queue's.
|
||||
* </p>
|
||||
*/
|
||||
public void completeScan();
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* BaseConsumer - the base set of methods for a consumer.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract interface BaseConsumer
|
||||
{
|
||||
/**
|
||||
* This is the id for the consumer.
|
||||
*
|
||||
* @return the consumer id.
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* The human readable description for this consumer.
|
||||
*
|
||||
* @return the human readable description for this consumer.
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Flag indicating permanance of consumer. (if it can be disabled or not)
|
||||
*
|
||||
* @return true indicating that consumer is permanent and cannot be disabled.
|
||||
*/
|
||||
public boolean isPermanent();
|
||||
|
||||
/**
|
||||
* Add a consumer monitor to the consumer.
|
||||
*
|
||||
* @param monitor the monitor to add.
|
||||
*/
|
||||
public void addConsumerMonitor( ConsumerMonitor monitor );
|
||||
|
||||
/**
|
||||
* Remove a consumer monitor.
|
||||
*
|
||||
* @param monitor the monitor to remove.
|
||||
*/
|
||||
public void removeConsumerMonitor( ConsumerMonitor monitor );
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.archiva.repository.consumer;
|
||||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -20,7 +20,6 @@ package org.apache.maven.archiva.repository.consumer;
|
|||
*/
|
||||
|
||||
import org.apache.maven.archiva.common.ArchivaException;
|
||||
import org.apache.maven.archiva.common.utils.BaseFile;
|
||||
|
||||
/**
|
||||
* ConsumerException - details about the failure of a consumer.
|
||||
|
@ -31,22 +30,13 @@ import org.apache.maven.archiva.common.utils.BaseFile;
|
|||
public class ConsumerException
|
||||
extends ArchivaException
|
||||
{
|
||||
private BaseFile file;
|
||||
|
||||
public ConsumerException( BaseFile file, String message, Throwable cause )
|
||||
public ConsumerException( String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public ConsumerException( BaseFile file, String message )
|
||||
public ConsumerException( String message )
|
||||
{
|
||||
super( message );
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public BaseFile getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ConsumerMonitor - a monitor for consumers.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ConsumerMonitor
|
||||
{
|
||||
/**
|
||||
* A consumer error event.
|
||||
*
|
||||
* @param consumer the consumer that caused the error.
|
||||
* @param type the type of error.
|
||||
* @param message the message about the error.
|
||||
*/
|
||||
public void consumerError( BaseConsumer consumer, String type, String message );
|
||||
|
||||
/**
|
||||
* A consumer warning event.
|
||||
*
|
||||
* @param consumer the consumer that caused the warning.
|
||||
* @param type the type of warning.
|
||||
* @param message the message about the warning.
|
||||
*/
|
||||
public void consumerWarning( BaseConsumer consumer, String type, String message );
|
||||
|
||||
/**
|
||||
* A consumer informational event.
|
||||
*
|
||||
* @param consumer the consumer that caused the informational message.
|
||||
* @param message the message.
|
||||
*/
|
||||
public void consumerInfo( BaseConsumer consumer, String message );
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
|
||||
/*
|
||||
* 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.BaseFile;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A consumer of content (files) in the repository.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface RepositoryContentConsumer extends BaseConsumer
|
||||
{
|
||||
/**
|
||||
* Get the list of included file patterns for this consumer.
|
||||
*
|
||||
* @return the list of {@link String} patterns. (example: <code>"**<span />/*.pom"</code>)
|
||||
*/
|
||||
public List getIncludes();
|
||||
|
||||
/**
|
||||
* Get the list of excluded file patterns for this consumer.
|
||||
*
|
||||
* @return the list of {@link String} patterns. (example: <code>"**<span />/*.pom"</code>) - (can be null for no exclusions)
|
||||
*/
|
||||
public List getExcludes();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event that triggers at the beginning of a scan.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
|
||||
* generally start tracking the scan as a whole.
|
||||
* </p>
|
||||
*
|
||||
* @param repository the repository that this consumer is being used for.
|
||||
* @throws ConsumerException if there was a problem with using the provided repository with the consumer.
|
||||
*/
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event indicating a file is to be processed by this consumer.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track
|
||||
* the files to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()}
|
||||
* event.
|
||||
* </p>
|
||||
*
|
||||
* @param path the relative file path (in the repository) to process.
|
||||
* @throws ConsumerException if there was a problem processing this file.
|
||||
*/
|
||||
public void processFile( String path ) throws ConsumerException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Event that triggers on the completion of a scan.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: If the consumer opted to batch up processing requests in the {@link #processFile(BaseFile)} event
|
||||
* this would be the last opportunity to drain any processing queue's.
|
||||
* </p>
|
||||
*/
|
||||
public void completeScan();
|
||||
}
|
|
@ -30,6 +30,21 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-consumer-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-repository-layer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-digest</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,236 @@
|
|||
package org.apache.maven.archiva.consumers.core;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.FileType;
|
||||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.codehaus.plexus.digest.ChecksumFile;
|
||||
import org.codehaus.plexus.digest.Digester;
|
||||
import org.codehaus.plexus.digest.DigesterException;
|
||||
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 java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ArtifactMissingChecksumsConsumer - Create missing checksums for the artifact.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
* @plexus.component role-hint="create-missing-checksums"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ArtifactMissingChecksumsConsumer extends AbstractMonitoredConsumer
|
||||
implements RepositoryContentConsumer, RegistryListener, Initializable
|
||||
{
|
||||
/**
|
||||
* @plexus.configuration default-value="create-missing-checksums"
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="Create Missing Checksums (.sha1 & .md5)"
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout"
|
||||
*/
|
||||
private Map bidirectionalLayoutMap;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="sha1"
|
||||
*/
|
||||
private Digester digestSha1;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="md5";
|
||||
*/
|
||||
private Digester digestMd5;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ChecksumFile checksum;
|
||||
|
||||
private static final String TYPE_CHECKSUM_NOT_FILE = "checksum-bad-not-file";
|
||||
|
||||
private static final String TYPE_CHECKSUM_CANNOT_CALC = "checksum-calc-failure";
|
||||
|
||||
private static final String TYPE_CHECKSUM_CANNOT_CREATE = "checksum-create-failure";
|
||||
|
||||
private ArchivaRepository repository;
|
||||
|
||||
private File repositoryDir;
|
||||
|
||||
private BidirectionalRepositoryLayout layout;
|
||||
|
||||
private List propertyNameTriggers = new ArrayList();
|
||||
|
||||
private List includes = new ArrayList();
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
|
||||
String layoutName = repository.getModel().getLayoutName();
|
||||
if ( !bidirectionalLayoutMap.containsKey( layoutName ) )
|
||||
{
|
||||
throw new ConsumerException( "Unable to process repository with layout [" + layoutName
|
||||
+ "] as there is no coresponding " + BidirectionalRepositoryLayout.class.getName()
|
||||
+ " implementation available." );
|
||||
}
|
||||
|
||||
this.layout = (BidirectionalRepositoryLayout) bidirectionalLayoutMap.get( layoutName );
|
||||
}
|
||||
|
||||
public void completeScan()
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public List getExcludes()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List getIncludes()
|
||||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public void processFile( String path ) throws ConsumerException
|
||||
{
|
||||
createIfMissing( path, digestSha1 );
|
||||
createIfMissing( path, digestMd5 );
|
||||
}
|
||||
|
||||
private void createIfMissing( String path, Digester digester )
|
||||
{
|
||||
File checksumFile = new File( this.repositoryDir, path + digester.getFilenameExtension() );
|
||||
if ( !checksumFile.exists() )
|
||||
{
|
||||
try
|
||||
{
|
||||
checksum.createChecksum( new File( this.repositoryDir, path ), digester );
|
||||
triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath() );
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC, "Cannot calculate checksum for file " + checksumFile
|
||||
+ ": " + e.getMessage() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE, "Cannot create checksum for file " + checksumFile
|
||||
+ ": " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
else if ( !checksumFile.isFile() )
|
||||
{
|
||||
triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE, "Checksum file " + checksumFile.getAbsolutePath()
|
||||
+ " is not a file." );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( propertyNameTriggers.contains( propertyName ) )
|
||||
{
|
||||
initIncludes();
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
private void initIncludes()
|
||||
{
|
||||
includes.clear();
|
||||
|
||||
FileType artifactTypes = configuration.getConfiguration().getRepositoryScanning().getFileTypeById( "artifacts" );
|
||||
if ( artifactTypes != null )
|
||||
{
|
||||
includes.addAll( artifactTypes.getPatterns() );
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() throws InitializationException
|
||||
{
|
||||
propertyNameTriggers = new ArrayList();
|
||||
propertyNameTriggers.add( "repositoryScanning" );
|
||||
propertyNameTriggers.add( "fileTypes" );
|
||||
propertyNameTriggers.add( "fileType" );
|
||||
propertyNameTriggers.add( "patterns" );
|
||||
propertyNameTriggers.add( "pattern" );
|
||||
|
||||
configuration.addChangeListener( this );
|
||||
|
||||
initIncludes();
|
||||
|
||||
if ( includes.isEmpty() )
|
||||
{
|
||||
throw new InitializationException( "Unable to use " + getId() + " due to empty includes list." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
package org.apache.maven.archiva.consumers.core;
|
||||
|
||||
/*
|
||||
* 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.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.codehaus.plexus.digest.ChecksumFile;
|
||||
import org.codehaus.plexus.digest.Digester;
|
||||
import org.codehaus.plexus.digest.DigesterException;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ValidateChecksumConsumer - validate the provided checksum against the file it represents.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role-hint="validate-checksums"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ValidateChecksumConsumer extends AbstractMonitoredConsumer
|
||||
implements RepositoryContentConsumer, Initializable
|
||||
{
|
||||
private static final String NOT_VALID_CHECKSUM = "checksum-not-valid";
|
||||
|
||||
private static final String CHECKSUM_NOT_FOUND = "checksum-not-found";
|
||||
|
||||
private static final String CHECKSUM_DIGESTER_FAILURE = "checksum-digester-failure";
|
||||
|
||||
private static final String CHECKSUM_IO_ERROR = "checksum-io-error";
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="validate-checksums"
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="Validate checksums against file."
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ChecksumFile checksum;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.codehaus.plexus.digest.Digester"
|
||||
*/
|
||||
private List digesterList;
|
||||
|
||||
private ArchivaRepository repository;
|
||||
|
||||
private File repositoryDir;
|
||||
|
||||
private List includes = new ArrayList();
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
}
|
||||
|
||||
public void completeScan()
|
||||
{
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
public List getExcludes()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List getIncludes()
|
||||
{
|
||||
return this.includes;
|
||||
}
|
||||
|
||||
public void processFile( String path ) throws ConsumerException
|
||||
{
|
||||
File checksumFile = new File( this.repositoryDir, path );
|
||||
try
|
||||
{
|
||||
if ( !checksum.isValidChecksum( checksumFile ) )
|
||||
{
|
||||
triggerConsumerWarning( NOT_VALID_CHECKSUM, "The checksum for " + checksumFile + " is invalid." );
|
||||
}
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
triggerConsumerError( CHECKSUM_NOT_FOUND, "File not found during checksum validation: " + e.getMessage() );
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
triggerConsumerError( CHECKSUM_DIGESTER_FAILURE, "Digester failure during checksum validation on " + checksumFile );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
triggerConsumerError( CHECKSUM_IO_ERROR, "Checksum I/O error during validation on " + checksumFile );
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() throws InitializationException
|
||||
{
|
||||
for ( Iterator itDigesters = digesterList.iterator(); itDigesters.hasNext(); )
|
||||
{
|
||||
Digester digester = (Digester) itDigesters.next();
|
||||
includes.add( "**/*" + digester.getFilenameExtension() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,21 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-database</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-consumer-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-repository-layer</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
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.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.FileType;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.RepositoryContent;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
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 java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role-hint="update-db-artifact"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ArtifactUpdateDatabaseConsumer extends AbstractMonitoredConsumer
|
||||
implements RepositoryContentConsumer, RegistryListener, Initializable
|
||||
{
|
||||
private static final String TYPE_NOT_ARTIFACT = "file-not-artifact";
|
||||
|
||||
private static final String DB_ERROR = "db-error";
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="update-db-artifact"
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="Update the Artifact in the Database"
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
private ArchivaDAO dao;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout"
|
||||
*/
|
||||
private Map bidirectionalLayoutMap;
|
||||
|
||||
private ArchivaRepository repository;
|
||||
|
||||
private File repositoryDir;
|
||||
|
||||
private BidirectionalRepositoryLayout layout;
|
||||
|
||||
private List propertyNameTriggers = new ArrayList();
|
||||
|
||||
private List includes = new ArrayList();
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public List getExcludes()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List getIncludes()
|
||||
{
|
||||
return this.includes;
|
||||
}
|
||||
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
|
||||
String layoutName = repository.getModel().getLayoutName();
|
||||
if ( !bidirectionalLayoutMap.containsKey( layoutName ) )
|
||||
{
|
||||
throw new ConsumerException( "Unable to process repository with layout [" + layoutName
|
||||
+ "] as there is no coresponding " + BidirectionalRepositoryLayout.class.getName()
|
||||
+ " implementation available." );
|
||||
}
|
||||
|
||||
this.layout = (BidirectionalRepositoryLayout) bidirectionalLayoutMap.get( layoutName );
|
||||
}
|
||||
|
||||
public void processFile( String path ) throws ConsumerException
|
||||
{
|
||||
try
|
||||
{
|
||||
ArchivaArtifact artifact = layout.toArtifact( path );
|
||||
|
||||
RepositoryContent repoContent = artifact.getModel().getContentKey();
|
||||
repoContent.setRepositoryId( this.repository.getId() );
|
||||
|
||||
// Calculate the hashcodes.
|
||||
|
||||
|
||||
dao.saveArtifact( artifact.getModel() );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: "
|
||||
+ e.getMessage() );
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
{
|
||||
triggerConsumerError( DB_ERROR, "Unable to save artifact to database: " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public void completeScan()
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( propertyNameTriggers.contains( propertyName ) )
|
||||
{
|
||||
initIncludes();
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
private void initIncludes()
|
||||
{
|
||||
includes.clear();
|
||||
|
||||
FileType artifactTypes = configuration.getConfiguration().getRepositoryScanning().getFileTypeById( "artifacts" );
|
||||
if ( artifactTypes != null )
|
||||
{
|
||||
includes.addAll( artifactTypes.getPatterns() );
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() throws InitializationException
|
||||
{
|
||||
propertyNameTriggers = new ArrayList();
|
||||
propertyNameTriggers.add( "repositoryScanning" );
|
||||
propertyNameTriggers.add( "fileTypes" );
|
||||
propertyNameTriggers.add( "fileType" );
|
||||
propertyNameTriggers.add( "patterns" );
|
||||
propertyNameTriggers.add( "pattern" );
|
||||
|
||||
configuration.addChangeListener( this );
|
||||
|
||||
initIncludes();
|
||||
|
||||
if ( includes.isEmpty() )
|
||||
{
|
||||
throw new InitializationException( "Unable to use " + getId() + " due to empty includes list." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,21 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-indexer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-consumer-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-repository-layer</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.archiva.consumers;
|
||||
package org.apache.maven.archiva.consumers.lucene;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -0,0 +1,153 @@
|
|||
package org.apache.maven.archiva.consumers.lucene;
|
||||
|
||||
/*
|
||||
* 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.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.FileType;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IndexContentConsumer - generic full file content indexing consumer.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role-hint="index-content"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class IndexContentConsumer extends AbstractMonitoredConsumer
|
||||
implements RepositoryContentConsumer, RegistryListener, Initializable
|
||||
{
|
||||
/**
|
||||
* @plexus.configuration default-value="index-content"
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="Text and XML file contents indexing"
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
private List propertyNameTriggers = new ArrayList();
|
||||
|
||||
private List includes = new ArrayList();
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean isPermanent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public List getExcludes()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List getIncludes()
|
||||
{
|
||||
return this.includes;
|
||||
}
|
||||
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
}
|
||||
|
||||
public void processFile( String path ) throws ConsumerException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void completeScan()
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( propertyNameTriggers.contains( propertyName ) )
|
||||
{
|
||||
initIncludes();
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
private void initIncludes()
|
||||
{
|
||||
includes.clear();
|
||||
|
||||
FileType artifactTypes =
|
||||
configuration.getConfiguration().getRepositoryScanning().getFileTypeById( "indexable-content" );
|
||||
if ( artifactTypes != null )
|
||||
{
|
||||
includes.addAll( artifactTypes.getPatterns() );
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() throws InitializationException
|
||||
{
|
||||
propertyNameTriggers = new ArrayList();
|
||||
propertyNameTriggers.add( "repositoryScanning" );
|
||||
propertyNameTriggers.add( "fileTypes" );
|
||||
propertyNameTriggers.add( "fileType" );
|
||||
propertyNameTriggers.add( "patterns" );
|
||||
propertyNameTriggers.add( "pattern" );
|
||||
|
||||
configuration.addChangeListener( this );
|
||||
|
||||
initIncludes();
|
||||
|
||||
if ( includes.isEmpty() )
|
||||
{
|
||||
throw new InitializationException( "Unable to use " + getId() + " due to empty includes list." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,8 +32,10 @@
|
|||
<modules>
|
||||
<module>archiva-consumer-api</module>
|
||||
<module>archiva-core-consumers</module>
|
||||
<!--
|
||||
<module>archiva-database-consumers</module>
|
||||
<module>archiva-lucene-consumers</module>
|
||||
<module>archiva-signature-consumers</module>
|
||||
-->
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -30,26 +30,12 @@
|
|||
<name>Archiva Base :: Indexer</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact-manager</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.plexus.cache</groupId>
|
||||
<artifactId>plexus-cache-hashmap</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
|
@ -68,10 +54,6 @@
|
|||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-digest</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-repository-metadata</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package org.apache.maven.archiva.indexer;
|
||||
|
||||
public class ArtifactKeys
|
||||
{
|
||||
public static final String GROUPID = "groupId";
|
||||
|
||||
public static final String GROUPID_EXACT = GROUPID + "_u";
|
||||
|
||||
public static final String ARTIFACTID = "artifactId";
|
||||
|
||||
public static final String ARTIFACTID_EXACT = ARTIFACTID + "_u";
|
||||
|
||||
public static final String VERSION = "version";
|
||||
|
||||
public static final String VERSION_EXACT = VERSION + "_u";
|
||||
|
||||
public static final String TYPE = "type";
|
||||
|
||||
public static final String CLASSIFIER = "classifier";
|
||||
}
|
|
@ -19,29 +19,46 @@ package org.apache.maven.archiva.indexer;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.indexer.query.Query;
|
||||
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Maintain an artifact index on the repository.
|
||||
* Common access methods for a Repository Content index.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public interface RepositoryArtifactIndex
|
||||
public interface RepositoryContentIndex
|
||||
{
|
||||
/**
|
||||
* Indexes the artifacts found within the specified list of index records. If the artifacts are already in the
|
||||
* repository they are updated.
|
||||
* Indexes the records.
|
||||
*
|
||||
* @param records the records to index
|
||||
* @throws RepositoryIndexException if there is a problem indexing the records
|
||||
* @param records list of {@link LuceneRepositoryContentRecord} objects.
|
||||
* @throws RepositoryIndexException if there is a problem indexing the records.
|
||||
*/
|
||||
void indexRecords( Collection records )
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Modify (potentially) existing records in the index.
|
||||
*
|
||||
* @param records the collection of {@link LuceneRepositoryContentRecord} objects to modify in the index.
|
||||
* @throws RepositoryIndexException if there is a problem modifying the records.
|
||||
*/
|
||||
public void modifyRecords( Collection records )
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Modify an existing (potential) record in the index.
|
||||
*
|
||||
* @param record the record to modify.
|
||||
* @throws RepositoryIndexException if there is a problem modifying the record.
|
||||
*/
|
||||
public void modifyRecord( LuceneRepositoryContentRecord record )
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Search the index based on the search criteria specified. Returns a list of index records.
|
||||
|
@ -75,7 +92,7 @@ public interface RepositoryArtifactIndex
|
|||
/**
|
||||
* Retrieve all records in the index.
|
||||
*
|
||||
* @return the records
|
||||
* @return the collection of {@link LuceneRepositoryContentRecord} objects.
|
||||
* @throws RepositoryIndexSearchException if there was an error searching the index
|
||||
*/
|
||||
Collection getAllRecords()
|
||||
|
@ -89,64 +106,11 @@ public interface RepositoryArtifactIndex
|
|||
*/
|
||||
Collection getAllRecordKeys()
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Indexes the artifact specified. If the artifact is already in the repository they it is updated.
|
||||
* This method should use less memory than indexRecords as the records can be created and disposed of on the fly.
|
||||
*
|
||||
* @param artifact the artifact to index
|
||||
* @param factory the artifact to record factory
|
||||
* @throws RepositoryIndexException if there is a problem indexing the artifacts
|
||||
*/
|
||||
void indexArtifact( Artifact artifact, RepositoryIndexRecordFactory factory )
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Indexes the artifacts found within the specified list. If the artifacts are already in the
|
||||
* repository they are updated. This method should use less memory than indexRecords as the records can be
|
||||
* created and disposed of on the fly.
|
||||
*
|
||||
* @param artifacts the artifacts to index
|
||||
* @param factory the artifact to record factory
|
||||
* @throws RepositoryIndexException if there is a problem indexing the artifacts
|
||||
* Get the index directory.
|
||||
*
|
||||
* @return the index directory.
|
||||
*/
|
||||
void indexArtifacts( List artifacts, RepositoryIndexRecordFactory factory )
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Get all the group IDs in the index.
|
||||
*
|
||||
* @return list of groups as strings
|
||||
* @throws RepositoryIndexException if there is a problem searching for the group ID
|
||||
*/
|
||||
List getAllGroupIds()
|
||||
throws RepositoryIndexException;
|
||||
|
||||
/**
|
||||
* Get the list of artifact IDs in a group in the index.
|
||||
*
|
||||
* @param groupId the group ID to search
|
||||
* @return the list of artifact ID strings
|
||||
* @throws RepositoryIndexSearchException if there is a problem searching for the group ID
|
||||
*/
|
||||
List getArtifactIds( String groupId )
|
||||
throws RepositoryIndexSearchException;
|
||||
|
||||
/**
|
||||
* Get the list of available versions for a given artifact.
|
||||
*
|
||||
* @param groupId the group ID to search for
|
||||
* @param artifactId the artifact ID to search for
|
||||
* @return the list of version strings
|
||||
* @throws RepositoryIndexSearchException if there is a problem searching for the artifact
|
||||
*/
|
||||
List getVersions( String groupId, String artifactId )
|
||||
throws RepositoryIndexSearchException;
|
||||
|
||||
/**
|
||||
* Get the time when the index was last updated. Note that this does not monitor external processes.
|
||||
*
|
||||
* @return the last updated time, or 0 if it has not been updated since the class was instantiated.
|
||||
*/
|
||||
long getLastUpdatedTime();
|
||||
File getIndexDirectory();
|
||||
}
|
|
@ -19,33 +19,36 @@ package org.apache.maven.archiva.indexer;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
|
||||
/**
|
||||
* Obtain an index instance.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public interface RepositoryArtifactIndexFactory
|
||||
public interface RepositoryContentIndexFactory
|
||||
{
|
||||
/**
|
||||
* Plexus role.
|
||||
*/
|
||||
String ROLE = RepositoryArtifactIndexFactory.class.getName();
|
||||
|
||||
/**
|
||||
* Method to create an instance of the standard index.
|
||||
* Method to create an instance of the bytecode index.
|
||||
*
|
||||
* @param indexPath the path where the index will be created/updated
|
||||
* @param repository the repository to create the content index from.
|
||||
* @return the index instance
|
||||
*/
|
||||
RepositoryArtifactIndex createStandardIndex( File indexPath );
|
||||
|
||||
RepositoryContentIndex createBytecodeIndex( ArchivaRepository repository );
|
||||
|
||||
/**
|
||||
* Method to create an instance of the minimal index.
|
||||
* Method to create an instance of the file content index.
|
||||
*
|
||||
* @param indexPath the path where the index will be created/updated
|
||||
* @param repository the repository to create the file content index from.
|
||||
* @return the index instance
|
||||
*/
|
||||
RepositoryArtifactIndex createMinimalIndex( File indexPath );
|
||||
RepositoryContentIndex createFileContentIndex( ArchivaRepository repository );
|
||||
|
||||
/**
|
||||
* Method to create an instance of the hashcode index.
|
||||
*
|
||||
* @param repository the repository to create the content index from.
|
||||
* @return the index instance
|
||||
*/
|
||||
RepositoryContentIndex createHashcodeIndex( ArchivaRepository repository );
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.LowerCaseFilter;
|
||||
import org.apache.lucene.analysis.StopAnalyzer;
|
||||
import org.apache.lucene.analysis.StopFilter;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.maven.archiva.indexer.ArtifactKeys;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.ClassnameTokenizer;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.FilenamesTokenizer;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.GroupIdTokenizer;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.VersionTokenizer;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* BytecodeAnalyzer
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeAnalyzer extends Analyzer
|
||||
{
|
||||
private static final Analyzer STANDARD = new StandardAnalyzer();
|
||||
|
||||
public TokenStream tokenStream( String field, Reader reader )
|
||||
{
|
||||
TokenStream tokenStream = null;
|
||||
|
||||
if ( BytecodeKeys.CLASSES.equals( field ) )
|
||||
{
|
||||
tokenStream = new ClassnameTokenizer( reader );
|
||||
}
|
||||
else if ( BytecodeKeys.FILES.equals( field ) )
|
||||
{
|
||||
tokenStream = new FilenamesTokenizer( reader );
|
||||
}
|
||||
else if ( ArtifactKeys.GROUPID.equals( field ) )
|
||||
{
|
||||
tokenStream = new GroupIdTokenizer( reader );
|
||||
}
|
||||
else if ( ArtifactKeys.VERSION.equals( field ) )
|
||||
{
|
||||
tokenStream = new VersionTokenizer( reader );
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenStream = STANDARD.tokenStream( field, reader );
|
||||
}
|
||||
|
||||
return new LowerCaseFilter( new StopFilter( tokenStream, StopAnalyzer.ENGLISH_STOP_WORDS ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.lucene.document.Document;
|
||||
import org.apache.maven.archiva.indexer.ArtifactKeys;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneDocumentMaker;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneEntryConverter;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.platform.JavaArtifactHelper;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Converter for Bytecode records and documents.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeEntryConverter implements LuceneEntryConverter
|
||||
{
|
||||
|
||||
public Document convert( LuceneRepositoryContentRecord record )
|
||||
{
|
||||
if ( !( record instanceof BytecodeRecord ) )
|
||||
{
|
||||
throw new ClassCastException( "Unable to convert type " + record.getClass().getName() + " to "
|
||||
+ BytecodeRecord.class.getName() + "." );
|
||||
}
|
||||
|
||||
BytecodeRecord bytecode = (BytecodeRecord) record;
|
||||
|
||||
LuceneDocumentMaker doc = new LuceneDocumentMaker( bytecode );
|
||||
|
||||
// Artifact Reference
|
||||
doc.addFieldTokenized( ArtifactKeys.GROUPID, bytecode.getArtifact().getGroupId() );
|
||||
doc.addFieldExact( ArtifactKeys.GROUPID_EXACT, bytecode.getArtifact().getGroupId() );
|
||||
doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, bytecode.getArtifact().getArtifactId() );
|
||||
doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, bytecode.getArtifact().getArtifactId() );
|
||||
doc.addFieldTokenized( ArtifactKeys.VERSION, bytecode.getArtifact().getVersion() );
|
||||
doc.addFieldExact( ArtifactKeys.VERSION_EXACT, bytecode.getArtifact().getVersion() );
|
||||
doc.addFieldTokenized( ArtifactKeys.TYPE, bytecode.getArtifact().getType() );
|
||||
doc.addFieldUntokenized( ArtifactKeys.CLASSIFIER, bytecode.getArtifact().getClassifier() );
|
||||
|
||||
// Bytecode Specifics
|
||||
doc.addFieldExact( BytecodeKeys.JDK, JavaArtifactHelper.getJavaDetails( bytecode.getArtifact() ).getJdk() );
|
||||
doc.addFieldTokenized( BytecodeKeys.CLASSES, bytecode.getClasses() );
|
||||
doc.addFieldTokenized( BytecodeKeys.METHODS, bytecode.getMethods() );
|
||||
doc.addFieldTokenized( BytecodeKeys.FILES, bytecode.getFiles() );
|
||||
|
||||
return doc.getDocument();
|
||||
}
|
||||
|
||||
public LuceneRepositoryContentRecord convert( Document document ) throws ParseException
|
||||
{
|
||||
BytecodeRecord record = new BytecodeRecord();
|
||||
|
||||
// Artifact Reference
|
||||
String groupId = document.get( ArtifactKeys.GROUPID );
|
||||
String artifactId = document.get( ArtifactKeys.ARTIFACTID );
|
||||
String version = document.get( ArtifactKeys.VERSION );
|
||||
String classifier = document.get( ArtifactKeys.CLASSIFIER );
|
||||
String type = document.get( ArtifactKeys.TYPE );
|
||||
|
||||
ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type );
|
||||
record.setArtifact( artifact );
|
||||
|
||||
// Bytecode Specifics
|
||||
JavaArtifactHelper.getJavaDetails( record.getArtifact() ).setJdk( document.get( BytecodeKeys.JDK ) );
|
||||
record.setClasses( getList( document, BytecodeKeys.CLASSES ) );
|
||||
record.setMethods( getList( document, BytecodeKeys.METHODS ) );
|
||||
record.setFiles( getList( document, BytecodeKeys.FILES ) );
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
public List getList( Document document, String key )
|
||||
{
|
||||
String rawlist = document.get( key );
|
||||
|
||||
if ( rawlist == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List ret = new ArrayList();
|
||||
ret.addAll( Arrays.asList( rawlist.split( "\n" ) ) );
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneEntryConverter;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
|
||||
|
||||
/**
|
||||
* BytecodeHandlers
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeHandlers implements LuceneIndexHandlers
|
||||
{
|
||||
private BytecodeAnalyzer analyzer;
|
||||
|
||||
private BytecodeEntryConverter converter;
|
||||
|
||||
public BytecodeHandlers()
|
||||
{
|
||||
converter = new BytecodeEntryConverter();
|
||||
analyzer = new BytecodeAnalyzer();
|
||||
}
|
||||
|
||||
public Analyzer getAnalyzer()
|
||||
{
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
public LuceneEntryConverter getConverter()
|
||||
{
|
||||
return converter;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.indexer.ArtifactKeys;
|
||||
|
||||
/**
|
||||
* BytecodeKeys
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeKeys extends ArtifactKeys
|
||||
{
|
||||
public static final String CLASSES = "classes";
|
||||
|
||||
public static final String METHODS = "methods";
|
||||
|
||||
public static final String FILES = "files";
|
||||
|
||||
public static final String JDK = "jdk";
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Lucene Record for Bytecode information.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeRecord implements LuceneRepositoryContentRecord
|
||||
{
|
||||
private ArchivaArtifact artifact;
|
||||
|
||||
private String filename;
|
||||
|
||||
private List classes;
|
||||
|
||||
private List methods;
|
||||
|
||||
private List files;
|
||||
|
||||
public ArchivaArtifact getArtifact()
|
||||
{
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public List getClasses()
|
||||
{
|
||||
return classes;
|
||||
}
|
||||
|
||||
public List getFiles()
|
||||
{
|
||||
return files;
|
||||
}
|
||||
|
||||
public List getMethods()
|
||||
{
|
||||
return methods;
|
||||
}
|
||||
|
||||
public String getPrimaryKey()
|
||||
{
|
||||
StringBuffer id = new StringBuffer();
|
||||
id.append( artifact.getGroupId() ).append( ":" );
|
||||
id.append( artifact.getArtifactId() ).append( ":" );
|
||||
id.append( artifact.getVersion() );
|
||||
|
||||
if ( artifact.getClassifier() != null )
|
||||
{
|
||||
id.append( ":" ).append( artifact.getClassifier() );
|
||||
}
|
||||
|
||||
id.append( ":" ).append( artifact.getType() );
|
||||
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
public void setArtifact( ArchivaArtifact artifact )
|
||||
{
|
||||
this.artifact = artifact;
|
||||
}
|
||||
|
||||
public void setClasses( List classes )
|
||||
{
|
||||
this.classes = classes;
|
||||
}
|
||||
|
||||
public void setFiles( List files )
|
||||
{
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public void setMethods( List methods )
|
||||
{
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + ( ( artifact == null ) ? 0 : artifact.hashCode() );
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final BytecodeRecord other = (BytecodeRecord) obj;
|
||||
|
||||
if ( artifact == null )
|
||||
{
|
||||
if ( other.artifact != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( !artifact.equals( other.artifact ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename( String filename )
|
||||
{
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append( "BytecodeRecord[" );
|
||||
sb.append( "artifact=" ).append( artifact );
|
||||
sb.append( ",filename=" ).append( filename );
|
||||
sb.append( "]" );
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.apache.maven.archiva.indexer.filecontent;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.FilenamesTokenizer;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* FileContentAnalyzer
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FileContentAnalyzer extends Analyzer
|
||||
{
|
||||
private static final Analyzer STANDARD = new StandardAnalyzer();
|
||||
|
||||
public TokenStream tokenStream( String field, Reader reader )
|
||||
{
|
||||
if ( FileContentKeys.FILENAME.equals( field ) )
|
||||
{
|
||||
return new FilenamesTokenizer( reader );
|
||||
}
|
||||
|
||||
return STANDARD.tokenStream( field, reader );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.apache.maven.archiva.indexer.filecontent;
|
||||
|
||||
/*
|
||||
* 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.lucene.document.Document;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneDocumentMaker;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneEntryConverter;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* FileContentConverter
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FileContentConverter implements LuceneEntryConverter
|
||||
{
|
||||
|
||||
public Document convert( LuceneRepositoryContentRecord record )
|
||||
{
|
||||
if ( !( record instanceof FileContentRecord ) )
|
||||
{
|
||||
throw new ClassCastException( "Unable to convert type " + record.getClass().getName() + " to "
|
||||
+ FileContentRecord.class.getName() + "." );
|
||||
}
|
||||
|
||||
FileContentRecord filecontent = (FileContentRecord) record;
|
||||
|
||||
LuceneDocumentMaker doc = new LuceneDocumentMaker( filecontent );
|
||||
|
||||
doc.addFieldTokenized( FileContentKeys.FILENAME, filecontent.getFile().getAbsolutePath() );
|
||||
doc.addFieldTokenized( FileContentKeys.CONTENT, filecontent.getContents() );
|
||||
|
||||
return doc.getDocument();
|
||||
}
|
||||
|
||||
public LuceneRepositoryContentRecord convert( Document document ) throws ParseException
|
||||
{
|
||||
FileContentRecord record = new FileContentRecord();
|
||||
|
||||
record.setFile( new File( document.get( FileContentKeys.FILENAME ) ) );
|
||||
record.setContents( document.get( FileContentKeys.CONTENT ) );
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.apache.maven.archiva.indexer.filecontent;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneEntryConverter;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
|
||||
|
||||
/**
|
||||
* FileContentHandlers
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FileContentHandlers implements LuceneIndexHandlers
|
||||
{
|
||||
private FileContentAnalyzer analyzer;
|
||||
|
||||
public Analyzer getAnalyzer()
|
||||
{
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
public LuceneEntryConverter getConverter()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.apache.maven.archiva.indexer.filecontent;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lucene Index Keys for the various fields in the FileContent index.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FileContentKeys
|
||||
{
|
||||
public static final String FILENAME = "filename";
|
||||
|
||||
public static final String CONTENT = "content";
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package org.apache.maven.archiva.indexer.filecontent;
|
||||
|
||||
/*
|
||||
* 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.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Lucene record for {@link File} contents.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FileContentRecord implements LuceneRepositoryContentRecord
|
||||
{
|
||||
private File file;
|
||||
|
||||
private String contents;
|
||||
|
||||
public String getContents()
|
||||
{
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void setContents( String contents )
|
||||
{
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile( File file )
|
||||
{
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getPrimaryKey()
|
||||
{
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + ( ( file == null ) ? 0 : file.hashCode() );
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final FileContentRecord other = (FileContentRecord) obj;
|
||||
|
||||
if ( file == null )
|
||||
{
|
||||
if ( other.file != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( !file.equals( other.file ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.apache.maven.archiva.indexer.hashcodes;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.LowerCaseFilter;
|
||||
import org.apache.lucene.analysis.StopAnalyzer;
|
||||
import org.apache.lucene.analysis.StopFilter;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.maven.archiva.indexer.ArtifactKeys;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.GroupIdTokenizer;
|
||||
import org.apache.maven.archiva.indexer.lucene.analyzers.VersionTokenizer;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* HashcodesAnalyzer
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class HashcodesAnalyzer extends Analyzer
|
||||
{
|
||||
private static final Analyzer STANDARD = new StandardAnalyzer();
|
||||
|
||||
public TokenStream tokenStream( String field, Reader reader )
|
||||
{
|
||||
TokenStream tokenStream = null;
|
||||
|
||||
if ( ArtifactKeys.GROUPID.equals( field ) )
|
||||
{
|
||||
tokenStream = new GroupIdTokenizer( reader );
|
||||
}
|
||||
else if ( ArtifactKeys.VERSION.equals( field ) )
|
||||
{
|
||||
tokenStream = new VersionTokenizer( reader );
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenStream = STANDARD.tokenStream( field, reader );
|
||||
}
|
||||
|
||||
return new LowerCaseFilter( new StopFilter( tokenStream, StopAnalyzer.ENGLISH_STOP_WORDS ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package org.apache.maven.archiva.indexer.hashcodes;
|
||||
|
||||
/*
|
||||
* 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.lucene.document.Document;
|
||||
import org.apache.maven.archiva.indexer.ArtifactKeys;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneDocumentMaker;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneEntryConverter;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Converter for Hashcode records and documents.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class HashcodesEntryConverter implements LuceneEntryConverter
|
||||
{
|
||||
|
||||
public Document convert( LuceneRepositoryContentRecord record )
|
||||
{
|
||||
if ( !( record instanceof HashcodesRecord ) )
|
||||
{
|
||||
throw new ClassCastException( "Unable to convert type " + record.getClass().getName() + " to "
|
||||
+ HashcodesRecord.class.getName() + "." );
|
||||
}
|
||||
|
||||
HashcodesRecord hashcodes = (HashcodesRecord) record;
|
||||
|
||||
LuceneDocumentMaker doc = new LuceneDocumentMaker( hashcodes );
|
||||
|
||||
// Artifact Reference
|
||||
doc.addFieldTokenized( ArtifactKeys.GROUPID, hashcodes.getArtifact().getGroupId() );
|
||||
doc.addFieldExact( ArtifactKeys.GROUPID_EXACT, hashcodes.getArtifact().getGroupId() );
|
||||
doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, hashcodes.getArtifact().getArtifactId() );
|
||||
doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, hashcodes.getArtifact().getArtifactId() );
|
||||
doc.addFieldTokenized( ArtifactKeys.VERSION, hashcodes.getArtifact().getVersion() );
|
||||
doc.addFieldExact( ArtifactKeys.VERSION_EXACT, hashcodes.getArtifact().getVersion() );
|
||||
doc.addFieldTokenized( ArtifactKeys.TYPE, hashcodes.getArtifact().getType() );
|
||||
doc.addFieldUntokenized( ArtifactKeys.CLASSIFIER, hashcodes.getArtifact().getClassifier() );
|
||||
|
||||
// Hashcode Specifics
|
||||
doc.addFieldUntokenized( HashcodesKeys.MD5, hashcodes.getArtifact().getModel().getChecksumMD5() );
|
||||
doc.addFieldUntokenized( HashcodesKeys.SHA1, hashcodes.getArtifact().getModel().getChecksumSHA1() );
|
||||
|
||||
return doc.getDocument();
|
||||
}
|
||||
|
||||
public LuceneRepositoryContentRecord convert( Document document ) throws ParseException
|
||||
{
|
||||
HashcodesRecord record = new HashcodesRecord();
|
||||
|
||||
// Artifact Reference
|
||||
String groupId = document.get( ArtifactKeys.GROUPID );
|
||||
String artifactId = document.get( ArtifactKeys.ARTIFACTID );
|
||||
String version = document.get( ArtifactKeys.VERSION );
|
||||
String classifier = document.get( ArtifactKeys.CLASSIFIER );
|
||||
String type = document.get( ArtifactKeys.TYPE );
|
||||
|
||||
ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type );
|
||||
record.setArtifact( artifact );
|
||||
|
||||
// Hashcode Specifics
|
||||
record.getArtifact().getModel().setChecksumMD5( document.get( HashcodesKeys.MD5 ) );
|
||||
record.getArtifact().getModel().setChecksumSHA1( document.get( HashcodesKeys.SHA1 ) );
|
||||
|
||||
return record;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.apache.maven.archiva.indexer.hashcodes;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneEntryConverter;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
|
||||
|
||||
/**
|
||||
* HashcodesHandlers
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class HashcodesHandlers implements LuceneIndexHandlers
|
||||
{
|
||||
private HashcodesAnalyzer analyzer;
|
||||
|
||||
private HashcodesEntryConverter converter;
|
||||
|
||||
public HashcodesHandlers()
|
||||
{
|
||||
converter = new HashcodesEntryConverter();
|
||||
analyzer = new HashcodesAnalyzer();
|
||||
}
|
||||
|
||||
public Analyzer getAnalyzer()
|
||||
{
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
public LuceneEntryConverter getConverter()
|
||||
{
|
||||
return converter;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.apache.maven.archiva.indexer.hashcodes;
|
||||
|
||||
/*
|
||||
* 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.indexer.ArtifactKeys;
|
||||
|
||||
/**
|
||||
* Lucene Index Keys for the various fields in the Hashcodes Index.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class HashcodesKeys extends ArtifactKeys
|
||||
{
|
||||
public static final String MD5 = "md5";
|
||||
|
||||
public static final String SHA1 = "sha1";
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package org.apache.maven.archiva.indexer.hashcodes;
|
||||
|
||||
/*
|
||||
* 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.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
|
||||
/**
|
||||
* Lucene record for {@link ArchivaArtifact} hashcodes information.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class HashcodesRecord implements LuceneRepositoryContentRecord
|
||||
{
|
||||
private ArchivaArtifact artifact;
|
||||
|
||||
private String filename;
|
||||
|
||||
public ArchivaArtifact getArtifact()
|
||||
{
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public void setArtifact( ArchivaArtifact artifact )
|
||||
{
|
||||
this.artifact = artifact;
|
||||
}
|
||||
|
||||
public String getPrimaryKey()
|
||||
{
|
||||
StringBuffer id = new StringBuffer();
|
||||
id.append( artifact.getGroupId() ).append( ":" );
|
||||
id.append( artifact.getArtifactId() ).append( ":" );
|
||||
id.append( artifact.getVersion() );
|
||||
|
||||
if ( artifact.getClassifier() != null )
|
||||
{
|
||||
id.append( ":" ).append( artifact.getClassifier() );
|
||||
}
|
||||
|
||||
id.append( ":" ).append( artifact.getType() );
|
||||
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + ( ( artifact == null ) ? 0 : artifact.hashCode() );
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final HashcodesRecord other = (HashcodesRecord) obj;
|
||||
|
||||
if ( artifact == null )
|
||||
{
|
||||
if ( other.artifact != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( !artifact.equals( other.artifact ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename( String filename )
|
||||
{
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append( "HashcodesRecord[" );
|
||||
sb.append( "artifact=" ).append( artifact );
|
||||
sb.append( ",filename=" ).append( filename );
|
||||
sb.append( "]" );
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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 org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LuceneDocumentMaker - a utility class for making lucene documents.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class LuceneDocumentMaker
|
||||
{
|
||||
public static final String PRIMARY_KEY = "pk";
|
||||
|
||||
private Document document;
|
||||
|
||||
/**
|
||||
* Construct a LuceneDocumentMaker based on the record provider.
|
||||
*
|
||||
* @param record the record.
|
||||
* @throws IllegalArgumentException if the primary key is invalid.
|
||||
*/
|
||||
public LuceneDocumentMaker( LuceneRepositoryContentRecord record ) throws IllegalArgumentException
|
||||
{
|
||||
if ( record == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Not allowed to have a null record provider." );
|
||||
}
|
||||
|
||||
String primaryKey = record.getPrimaryKey();
|
||||
|
||||
if ( primaryKey == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Not allowed to have a null primary key." );
|
||||
}
|
||||
|
||||
if ( primaryKey.trim().length() <= 0 )
|
||||
{
|
||||
throw new IllegalArgumentException( "Not allowed to have an empty primary key." );
|
||||
}
|
||||
|
||||
document = new Document();
|
||||
|
||||
document.add( new Field( PRIMARY_KEY, primaryKey, Field.Store.NO, Field.Index.UN_TOKENIZED ) );
|
||||
}
|
||||
|
||||
public LuceneDocumentMaker addFieldTokenized( String key, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( key, value, Field.Store.YES, Field.Index.TOKENIZED ) );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LuceneDocumentMaker addFieldTokenized( String key, List list )
|
||||
{
|
||||
if ( ( list != null ) && ( !list.isEmpty() ) )
|
||||
{
|
||||
return addFieldTokenized( key, StringUtils.join( list.iterator(), "\n" ) );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LuceneDocumentMaker addFieldUntokenized( String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.YES, Field.Index.UN_TOKENIZED ) );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LuceneDocumentMaker addFieldExact( String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.NO, Field.Index.UN_TOKENIZED ) );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Document getDocument()
|
||||
{
|
||||
return this.document;
|
||||
}
|
||||
}
|
|
@ -20,16 +20,15 @@ package org.apache.maven.archiva.indexer.lucene;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecord;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Converts repository records to Lucene documents.
|
||||
* A converter for {@link LuceneRepositoryContentRecord} to Lucene {@link Document} objects and back.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public interface LuceneIndexRecordConverter
|
||||
public interface LuceneEntryConverter
|
||||
{
|
||||
/**
|
||||
* Convert an index record to a Lucene document.
|
||||
|
@ -37,7 +36,7 @@ public interface LuceneIndexRecordConverter
|
|||
* @param record the record
|
||||
* @return the document
|
||||
*/
|
||||
Document convert( RepositoryIndexRecord record );
|
||||
Document convert( LuceneRepositoryContentRecord record );
|
||||
|
||||
/**
|
||||
* Convert a Lucene document to an index record.
|
||||
|
@ -46,6 +45,6 @@ public interface LuceneIndexRecordConverter
|
|||
* @return the record
|
||||
* @throws java.text.ParseException if there is a problem parsing a field (specifically, dates)
|
||||
*/
|
||||
RepositoryIndexRecord convert( Document document )
|
||||
LuceneRepositoryContentRecord convert( Document document )
|
||||
throws ParseException;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
|
||||
/**
|
||||
* The important bits and pieces for handling a specific lucene index
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface LuceneIndexHandlers
|
||||
{
|
||||
/**
|
||||
* Get the converter to use with this index.
|
||||
*
|
||||
* @return the converter to use.
|
||||
*/
|
||||
public LuceneEntryConverter getConverter();
|
||||
|
||||
/**
|
||||
* Get the analyzer to user with this index.
|
||||
*
|
||||
* @return the analzer to use.
|
||||
*/
|
||||
public Analyzer getAnalyzer();
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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 org.apache.lucene.document.DateTools;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.NumberTools;
|
||||
import org.apache.maven.archiva.indexer.record.MinimalArtifactIndexRecord;
|
||||
import org.apache.maven.archiva.indexer.record.MinimalIndexRecordFields;
|
||||
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecord;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Convert the minimal index record to a Lucene document.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class LuceneMinimalIndexRecordConverter
|
||||
implements LuceneIndexRecordConverter
|
||||
{
|
||||
public Document convert( RepositoryIndexRecord record )
|
||||
{
|
||||
MinimalArtifactIndexRecord rec = (MinimalArtifactIndexRecord) record;
|
||||
|
||||
Document document = new Document();
|
||||
addTokenizedField( document, MinimalIndexRecordFields.FILENAME, rec.getFilename() );
|
||||
addUntokenizedField( document, MinimalIndexRecordFields.LAST_MODIFIED,
|
||||
DateTools.timeToString( rec.getLastModified(), DateTools.Resolution.SECOND ) );
|
||||
addUntokenizedField( document, MinimalIndexRecordFields.FILE_SIZE, NumberTools.longToString( rec.getSize() ) );
|
||||
addUntokenizedField( document, MinimalIndexRecordFields.MD5, rec.getMd5Checksum() );
|
||||
addTokenizedField( document, MinimalIndexRecordFields.CLASSES,
|
||||
StringUtils.join( rec.getClasses().iterator(), "\n" ) );
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public RepositoryIndexRecord convert( Document document )
|
||||
throws ParseException
|
||||
{
|
||||
MinimalArtifactIndexRecord record = new MinimalArtifactIndexRecord();
|
||||
|
||||
record.setFilename( document.get( MinimalIndexRecordFields.FILENAME ) );
|
||||
record.setLastModified( DateTools.stringToTime( document.get( MinimalIndexRecordFields.LAST_MODIFIED ) ) );
|
||||
record.setSize( NumberTools.stringToLong( document.get( MinimalIndexRecordFields.FILE_SIZE ) ) );
|
||||
record.setMd5Checksum( document.get( MinimalIndexRecordFields.MD5 ) );
|
||||
record.setClasses( Arrays.asList( document.get( MinimalIndexRecordFields.CLASSES ).split( "\n" ) ) );
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
private static void addUntokenizedField( Document document, String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.YES, Field.Index.UN_TOKENIZED ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static void addTokenizedField( Document document, String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.YES, Field.Index.TOKENIZED ) );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,604 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.CharTokenizer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexModifier;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermEnum;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.Hits;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
|
||||
import org.apache.maven.archiva.indexer.query.Query;
|
||||
import org.apache.maven.archiva.indexer.record.MinimalIndexRecordFields;
|
||||
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecord;
|
||||
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
|
||||
import org.apache.maven.archiva.indexer.record.StandardIndexRecordFields;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Lucene implementation of a repository index.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class LuceneRepositoryArtifactIndex
|
||||
implements RepositoryArtifactIndex
|
||||
{
|
||||
/**
|
||||
* The location of the index on the file system.
|
||||
*/
|
||||
private File indexLocation;
|
||||
|
||||
/**
|
||||
* Convert repository records to Lucene documents.
|
||||
*/
|
||||
private LuceneIndexRecordConverter converter;
|
||||
|
||||
private static final String FLD_PK = "pk";
|
||||
|
||||
private static Analyzer luceneAnalyzer = new LuceneAnalyzer();
|
||||
|
||||
private static long lastUpdatedTime = 0;
|
||||
|
||||
public LuceneRepositoryArtifactIndex( File indexPath, LuceneIndexRecordConverter converter )
|
||||
{
|
||||
this.indexLocation = indexPath;
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
public void indexRecords( Collection records )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
deleteRecords( records );
|
||||
|
||||
addRecords( records );
|
||||
}
|
||||
|
||||
private void addRecords( Collection records )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
IndexWriter indexWriter;
|
||||
try
|
||||
{
|
||||
indexWriter = new IndexWriter( indexLocation, getAnalyzer(), !exists() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Unable to open index", e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for ( Iterator i = records.iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryIndexRecord record = (RepositoryIndexRecord) i.next();
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Document document = converter.convert( record );
|
||||
document.add(
|
||||
new Field( FLD_PK, record.getPrimaryKey(), Field.Store.NO, Field.Index.UN_TOKENIZED ) );
|
||||
|
||||
indexWriter.addDocument( document );
|
||||
}
|
||||
}
|
||||
|
||||
indexWriter.optimize();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Failed to add an index document", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexWriter );
|
||||
lastUpdatedTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public static Analyzer getAnalyzer()
|
||||
{
|
||||
return luceneAnalyzer;
|
||||
}
|
||||
|
||||
private static class LuceneAnalyzer
|
||||
extends Analyzer
|
||||
{
|
||||
private static final Analyzer STANDARD = new StandardAnalyzer();
|
||||
|
||||
public TokenStream tokenStream( String field, final Reader reader )
|
||||
{
|
||||
// do not tokenize field called 'element'
|
||||
if ( StandardIndexRecordFields.DEPENDENCIES.equals( field ) )
|
||||
{
|
||||
return new CharTokenizer( reader )
|
||||
{
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return c != '\n';
|
||||
}
|
||||
};
|
||||
}
|
||||
else if ( StandardIndexRecordFields.FILES.equals( field ) )
|
||||
{
|
||||
return new CharTokenizer( reader )
|
||||
{
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return c != '\n' && c != '/';
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
if ( StandardIndexRecordFields.CLASSES.equals( field ) || MinimalIndexRecordFields.CLASSES.equals( field ) )
|
||||
{
|
||||
return new CharTokenizer( reader )
|
||||
{
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return c != '\n' && c != '.';
|
||||
}
|
||||
|
||||
protected char normalize( char c )
|
||||
{
|
||||
return Character.toLowerCase( c );
|
||||
}
|
||||
};
|
||||
}
|
||||
else if ( StandardIndexRecordFields.GROUPID.equals( field ) )
|
||||
{
|
||||
return new CharTokenizer( reader )
|
||||
{
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return c != '.';
|
||||
}
|
||||
|
||||
protected char normalize( char c )
|
||||
{
|
||||
return Character.toLowerCase( c );
|
||||
}
|
||||
};
|
||||
}
|
||||
else if ( StandardIndexRecordFields.VERSION.equals( field ) ||
|
||||
StandardIndexRecordFields.BASE_VERSION.equals( field ) )
|
||||
{
|
||||
return new CharTokenizer( reader )
|
||||
{
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return c != '-';
|
||||
}
|
||||
};
|
||||
}
|
||||
else if ( StandardIndexRecordFields.FILENAME.equals( field ) ||
|
||||
MinimalIndexRecordFields.FILENAME.equals( field ) )
|
||||
{
|
||||
return new CharTokenizer( reader )
|
||||
{
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return c != '-' && c != '.' && c != '/';
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// use standard analyzer
|
||||
return STANDARD.tokenStream( field, reader );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRecords( Collection records )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
if ( exists() )
|
||||
{
|
||||
IndexReader indexReader = null;
|
||||
try
|
||||
{
|
||||
indexReader = IndexReader.open( indexLocation );
|
||||
|
||||
for ( Iterator i = records.iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryIndexRecord record = (RepositoryIndexRecord) i.next();
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Term term = new Term( FLD_PK, record.getPrimaryKey() );
|
||||
|
||||
indexReader.deleteDocuments( term );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error deleting document: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexReader );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection getAllRecords()
|
||||
throws RepositoryIndexSearchException
|
||||
{
|
||||
return search( new LuceneQuery( new MatchAllDocsQuery() ) );
|
||||
}
|
||||
|
||||
public Collection getAllRecordKeys()
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
return getAllFieldValues( FLD_PK );
|
||||
}
|
||||
|
||||
private List getAllFieldValues( String fieldName )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
List keys = new ArrayList();
|
||||
|
||||
if ( exists() )
|
||||
{
|
||||
IndexReader indexReader = null;
|
||||
TermEnum terms = null;
|
||||
try
|
||||
{
|
||||
indexReader = IndexReader.open( indexLocation );
|
||||
|
||||
terms = indexReader.terms( new Term( fieldName, "" ) );
|
||||
while ( fieldName.equals( terms.term().field() ) )
|
||||
{
|
||||
keys.add( terms.term().text() );
|
||||
|
||||
if ( !terms.next() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error deleting document: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexReader );
|
||||
closeQuietly( terms );
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
public void indexArtifacts( List artifacts, RepositoryIndexRecordFactory factory )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
IndexModifier indexModifier = null;
|
||||
try
|
||||
{
|
||||
indexModifier = new IndexModifier( indexLocation, getAnalyzer(), !exists() );
|
||||
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
RepositoryIndexRecord record = factory.createRecord( artifact );
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Term term = new Term( FLD_PK, record.getPrimaryKey() );
|
||||
|
||||
indexModifier.deleteDocuments( term );
|
||||
|
||||
Document document = converter.convert( record );
|
||||
document.add(
|
||||
new Field( FLD_PK, record.getPrimaryKey(), Field.Store.NO, Field.Index.UN_TOKENIZED ) );
|
||||
|
||||
indexModifier.addDocument( document );
|
||||
}
|
||||
}
|
||||
indexModifier.optimize();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexModifier );
|
||||
lastUpdatedTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public void indexArtifact( Artifact artifact, RepositoryIndexRecordFactory factory )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
IndexModifier indexModifier = null;
|
||||
try
|
||||
{
|
||||
indexModifier = new IndexModifier( indexLocation, getAnalyzer(), !exists() );
|
||||
|
||||
RepositoryIndexRecord record = factory.createRecord( artifact );
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Term term = new Term( FLD_PK, record.getPrimaryKey() );
|
||||
|
||||
indexModifier.deleteDocuments( term );
|
||||
|
||||
Document document = converter.convert( record );
|
||||
document.add( new Field( FLD_PK, record.getPrimaryKey(), Field.Store.NO, Field.Index.UN_TOKENIZED ) );
|
||||
|
||||
indexModifier.addDocument( document );
|
||||
}
|
||||
indexModifier.optimize();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexModifier );
|
||||
lastUpdatedTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public List getAllGroupIds()
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
return getAllFieldValues( StandardIndexRecordFields.GROUPID_EXACT );
|
||||
}
|
||||
|
||||
public List getArtifactIds( String groupId )
|
||||
throws RepositoryIndexSearchException
|
||||
{
|
||||
return searchField( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ),
|
||||
StandardIndexRecordFields.ARTIFACTID );
|
||||
}
|
||||
|
||||
public List getVersions( String groupId, String artifactId )
|
||||
throws RepositoryIndexSearchException
|
||||
{
|
||||
BooleanQuery query = new BooleanQuery();
|
||||
query.add( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ),
|
||||
BooleanClause.Occur.MUST );
|
||||
query.add( new TermQuery( new Term( StandardIndexRecordFields.ARTIFACTID_EXACT, artifactId ) ),
|
||||
BooleanClause.Occur.MUST );
|
||||
|
||||
return searchField( query, StandardIndexRecordFields.VERSION );
|
||||
}
|
||||
|
||||
public long getLastUpdatedTime()
|
||||
{
|
||||
return lastUpdatedTime;
|
||||
}
|
||||
|
||||
private List searchField( org.apache.lucene.search.Query luceneQuery, String fieldName )
|
||||
throws RepositoryIndexSearchException
|
||||
{
|
||||
Set results = new LinkedHashSet();
|
||||
|
||||
IndexSearcher searcher;
|
||||
try
|
||||
{
|
||||
searcher = new IndexSearcher( indexLocation.getAbsolutePath() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to open index: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Hits hits = searcher.search( luceneQuery );
|
||||
for ( int i = 0; i < hits.length(); i++ )
|
||||
{
|
||||
Document doc = hits.doc( i );
|
||||
|
||||
results.add( doc.get( fieldName ) );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( searcher );
|
||||
}
|
||||
return new ArrayList( results );
|
||||
}
|
||||
|
||||
public boolean exists()
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
if ( IndexReader.indexExists( indexLocation ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( !indexLocation.exists() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ( indexLocation.isDirectory() )
|
||||
{
|
||||
if ( indexLocation.listFiles().length > 1 )
|
||||
{
|
||||
throw new RepositoryIndexException( indexLocation + " is not a valid index directory." );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RepositoryIndexException( indexLocation + " is not a directory." );
|
||||
}
|
||||
}
|
||||
|
||||
public List search( Query query )
|
||||
throws RepositoryIndexSearchException
|
||||
{
|
||||
LuceneQuery lQuery = (LuceneQuery) query;
|
||||
|
||||
org.apache.lucene.search.Query luceneQuery = lQuery.getLuceneQuery();
|
||||
|
||||
IndexSearcher searcher;
|
||||
try
|
||||
{
|
||||
searcher = new IndexSearcher( indexLocation.getAbsolutePath() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to open index: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
List records = new ArrayList();
|
||||
try
|
||||
{
|
||||
Hits hits = searcher.search( luceneQuery );
|
||||
for ( int i = 0; i < hits.length(); i++ )
|
||||
{
|
||||
Document doc = hits.doc( i );
|
||||
|
||||
records.add( converter.convert( doc ) );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
|
||||
}
|
||||
catch ( ParseException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( searcher );
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexSearcher searcher )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( searcher != null )
|
||||
{
|
||||
searcher.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( TermEnum terms )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
if ( terms != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
terms.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexWriter indexWriter )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( indexWriter != null )
|
||||
{
|
||||
indexWriter.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// write should compain if it can't be closed, data probably not persisted
|
||||
throw new RepositoryIndexException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexModifier indexModifier )
|
||||
{
|
||||
if ( indexModifier != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
indexModifier.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexReader reader )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( reader != null )
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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.indexer.RepositoryArtifactIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Factory for Lucene artifact index instances.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @plexus.component role="org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory" role-hint="lucene"
|
||||
*/
|
||||
public class LuceneRepositoryArtifactIndexFactory
|
||||
implements RepositoryArtifactIndexFactory
|
||||
{
|
||||
public RepositoryArtifactIndex createStandardIndex( File indexPath )
|
||||
{
|
||||
return new LuceneRepositoryArtifactIndex( indexPath, new LuceneStandardIndexRecordConverter() );
|
||||
}
|
||||
|
||||
public RepositoryArtifactIndex createMinimalIndex( File indexPath )
|
||||
{
|
||||
return new LuceneRepositoryArtifactIndex( indexPath, new LuceneMinimalIndexRecordConverter() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,469 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexModifier;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermEnum;
|
||||
import org.apache.lucene.search.Hits;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
|
||||
import org.apache.maven.archiva.indexer.query.Query;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Lucene implementation of a repository index.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class LuceneRepositoryContentIndex implements RepositoryContentIndex
|
||||
{
|
||||
/**
|
||||
* The max field length for a field in a document.
|
||||
*/
|
||||
private static final int MAX_FIELD_LENGTH = 40000;
|
||||
|
||||
/**
|
||||
* The location of the index on the file system.
|
||||
*/
|
||||
private File indexLocation;
|
||||
|
||||
/**
|
||||
* The Lucene Index Handlers
|
||||
*/
|
||||
private LuceneIndexHandlers indexHandlers;
|
||||
|
||||
public LuceneRepositoryContentIndex( File indexDir, LuceneIndexHandlers handlers )
|
||||
{
|
||||
this.indexLocation = indexDir;
|
||||
this.indexHandlers = handlers;
|
||||
}
|
||||
|
||||
public void indexRecords( Collection records ) throws RepositoryIndexException
|
||||
{
|
||||
deleteRecords( records );
|
||||
|
||||
addRecords( records );
|
||||
}
|
||||
|
||||
public void modifyRecords( Collection records ) throws RepositoryIndexException
|
||||
{
|
||||
IndexModifier indexModifier = null;
|
||||
try
|
||||
{
|
||||
indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() );
|
||||
indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH );
|
||||
|
||||
for ( Iterator i = records.iterator(); i.hasNext(); )
|
||||
{
|
||||
LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) i.next();
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
|
||||
|
||||
indexModifier.deleteDocuments( term );
|
||||
|
||||
Document document = indexHandlers.getConverter().convert( record );
|
||||
|
||||
indexModifier.addDocument( document );
|
||||
}
|
||||
}
|
||||
indexModifier.optimize();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexModifier );
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyRecord( LuceneRepositoryContentRecord record ) throws RepositoryIndexException
|
||||
{
|
||||
IndexModifier indexModifier = null;
|
||||
try
|
||||
{
|
||||
indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() );
|
||||
indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH );
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
|
||||
|
||||
indexModifier.deleteDocuments( term );
|
||||
|
||||
Document document = indexHandlers.getConverter().convert( record );
|
||||
|
||||
indexModifier.addDocument( document );
|
||||
}
|
||||
indexModifier.optimize();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexModifier );
|
||||
}
|
||||
}
|
||||
|
||||
private void addRecords( Collection records ) throws RepositoryIndexException
|
||||
{
|
||||
IndexWriter indexWriter;
|
||||
try
|
||||
{
|
||||
indexWriter = new IndexWriter( indexLocation, indexHandlers.getAnalyzer(), !exists() );
|
||||
indexWriter.setMaxFieldLength( MAX_FIELD_LENGTH );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Unable to open index", e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for ( Iterator i = records.iterator(); i.hasNext(); )
|
||||
{
|
||||
LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) i.next();
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Document document = indexHandlers.getConverter().convert( record );
|
||||
|
||||
indexWriter.addDocument( document );
|
||||
}
|
||||
}
|
||||
|
||||
indexWriter.optimize();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Failed to add an index document", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexWriter );
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRecords( Collection records ) throws RepositoryIndexException
|
||||
{
|
||||
if ( exists() )
|
||||
{
|
||||
IndexReader indexReader = null;
|
||||
try
|
||||
{
|
||||
indexReader = IndexReader.open( indexLocation );
|
||||
|
||||
for ( Iterator i = records.iterator(); i.hasNext(); )
|
||||
{
|
||||
LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) i.next();
|
||||
|
||||
if ( record != null )
|
||||
{
|
||||
Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
|
||||
|
||||
indexReader.deleteDocuments( term );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error deleting document: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexReader );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection getAllRecords() throws RepositoryIndexSearchException
|
||||
{
|
||||
return search( new LuceneQuery( new MatchAllDocsQuery() ) );
|
||||
}
|
||||
|
||||
public Collection getAllRecordKeys() throws RepositoryIndexException
|
||||
{
|
||||
return getAllFieldValues( LuceneDocumentMaker.PRIMARY_KEY );
|
||||
}
|
||||
|
||||
private List getAllFieldValues( String fieldName ) throws RepositoryIndexException
|
||||
{
|
||||
List keys = new ArrayList();
|
||||
|
||||
if ( exists() )
|
||||
{
|
||||
IndexReader indexReader = null;
|
||||
TermEnum terms = null;
|
||||
try
|
||||
{
|
||||
indexReader = IndexReader.open( indexLocation );
|
||||
|
||||
terms = indexReader.terms( new Term( fieldName, "" ) );
|
||||
while ( fieldName.equals( terms.term().field() ) )
|
||||
{
|
||||
keys.add( terms.term().text() );
|
||||
|
||||
if ( !terms.next() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Error deleting document: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( indexReader );
|
||||
closeQuietly( terms );
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
// public List getAllGroupIds() throws RepositoryIndexException
|
||||
// {
|
||||
// return getAllFieldValues( StandardIndexRecordFields.GROUPID_EXACT );
|
||||
// }
|
||||
//
|
||||
// public List getArtifactIds( String groupId ) throws RepositoryIndexSearchException
|
||||
// {
|
||||
// return searchField( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ),
|
||||
// StandardIndexRecordFields.ARTIFACTID );
|
||||
// }
|
||||
//
|
||||
// public List getVersions( String groupId, String artifactId ) throws RepositoryIndexSearchException
|
||||
// {
|
||||
// BooleanQuery query = new BooleanQuery();
|
||||
// query.add( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ),
|
||||
// BooleanClause.Occur.MUST );
|
||||
// query.add( new TermQuery( new Term( StandardIndexRecordFields.ARTIFACTID_EXACT, artifactId ) ),
|
||||
// BooleanClause.Occur.MUST );
|
||||
//
|
||||
// return searchField( query, StandardIndexRecordFields.VERSION );
|
||||
// }
|
||||
|
||||
// private List searchField( org.apache.lucene.search.Query luceneQuery, String fieldName )
|
||||
// throws RepositoryIndexSearchException
|
||||
// {
|
||||
// Set results = new LinkedHashSet();
|
||||
//
|
||||
// IndexSearcher searcher;
|
||||
// try
|
||||
// {
|
||||
// searcher = new IndexSearcher( indexLocation.getAbsolutePath() );
|
||||
// }
|
||||
// catch ( IOException e )
|
||||
// {
|
||||
// throw new RepositoryIndexSearchException( "Unable to open index: " + e.getMessage(), e );
|
||||
// }
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// Hits hits = searcher.search( luceneQuery );
|
||||
// for ( int i = 0; i < hits.length(); i++ )
|
||||
// {
|
||||
// Document doc = hits.doc( i );
|
||||
//
|
||||
// results.add( doc.get( fieldName ) );
|
||||
// }
|
||||
// }
|
||||
// catch ( IOException e )
|
||||
// {
|
||||
// throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// closeQuietly( searcher );
|
||||
// }
|
||||
// return new ArrayList( results );
|
||||
// }
|
||||
|
||||
public boolean exists() throws RepositoryIndexException
|
||||
{
|
||||
if ( IndexReader.indexExists( indexLocation ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( !indexLocation.exists() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ( indexLocation.isDirectory() )
|
||||
{
|
||||
if ( indexLocation.listFiles().length > 1 )
|
||||
{
|
||||
throw new RepositoryIndexException( indexLocation + " is not a valid index directory." );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RepositoryIndexException( indexLocation + " is not a directory." );
|
||||
}
|
||||
}
|
||||
|
||||
public List search( Query query ) throws RepositoryIndexSearchException
|
||||
{
|
||||
LuceneQuery lQuery = (LuceneQuery) query;
|
||||
|
||||
org.apache.lucene.search.Query luceneQuery = lQuery.getLuceneQuery();
|
||||
|
||||
IndexSearcher searcher;
|
||||
try
|
||||
{
|
||||
searcher = new IndexSearcher( indexLocation.getAbsolutePath() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to open index: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
List records = new ArrayList();
|
||||
try
|
||||
{
|
||||
Hits hits = searcher.search( luceneQuery );
|
||||
for ( int i = 0; i < hits.length(); i++ )
|
||||
{
|
||||
Document doc = hits.doc( i );
|
||||
|
||||
records.add( indexHandlers.getConverter().convert( doc ) );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
|
||||
}
|
||||
catch ( ParseException e )
|
||||
{
|
||||
throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( searcher );
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexSearcher searcher )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( searcher != null )
|
||||
{
|
||||
searcher.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( TermEnum terms ) throws RepositoryIndexException
|
||||
{
|
||||
if ( terms != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
terms.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexWriter indexWriter ) throws RepositoryIndexException
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( indexWriter != null )
|
||||
{
|
||||
indexWriter.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// write should compain if it can't be closed, data probably not persisted
|
||||
throw new RepositoryIndexException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexModifier indexModifier )
|
||||
{
|
||||
if ( indexModifier != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
indexModifier.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeQuietly( IndexReader reader )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( reader != null )
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public File getIndexDirectory()
|
||||
{
|
||||
return this.indexLocation;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
|
||||
import org.apache.maven.archiva.indexer.bytecode.BytecodeHandlers;
|
||||
import org.apache.maven.archiva.indexer.filecontent.FileContentHandlers;
|
||||
import org.apache.maven.archiva.indexer.hashcodes.HashcodesHandlers;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Factory for Lucene repository content index instances.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.indexer.RepositoryContentIndexFactory" role-hint="lucene"
|
||||
*/
|
||||
public class LuceneRepositoryContentIndexFactory implements RepositoryContentIndexFactory
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
public RepositoryContentIndex createBytecodeIndex( ArchivaRepository repository )
|
||||
{
|
||||
File indexDir = toIndexDir( repository, "bytecode" );
|
||||
return new LuceneRepositoryContentIndex( indexDir, new BytecodeHandlers() );
|
||||
}
|
||||
|
||||
public RepositoryContentIndex createFileContentIndex( ArchivaRepository repository )
|
||||
{
|
||||
File indexDir = toIndexDir( repository, "filecontent" );
|
||||
return new LuceneRepositoryContentIndex( indexDir, new FileContentHandlers() );
|
||||
}
|
||||
|
||||
public RepositoryContentIndex createHashcodeIndex( ArchivaRepository repository )
|
||||
{
|
||||
File indexDir = toIndexDir( repository, "hashcodes" );
|
||||
return new LuceneRepositoryContentIndex( indexDir, new HashcodesHandlers() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the index directory for the provided repository.
|
||||
*
|
||||
* @param repository the repository to obtain the index directory from.
|
||||
* @param indexId the id of the index
|
||||
* @return the directory to put the index into.
|
||||
*/
|
||||
private File toIndexDir( ArchivaRepository repository, String indexId )
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new IllegalArgumentException( "Only supports managed repositories." );
|
||||
}
|
||||
|
||||
// Attempt to get the specified indexDir in the configuration first.
|
||||
RepositoryConfiguration repoConfig = configuration.getConfiguration().findRepositoryById( repository.getId() );
|
||||
File indexDir;
|
||||
|
||||
if ( repoConfig == null )
|
||||
{
|
||||
// No configured index dir, use the repository path instead.
|
||||
String repoPath = repository.getUrl().getPath();
|
||||
indexDir = new File( repoPath, ".index/" + indexId + "/" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use configured index dir.
|
||||
String repoPath = repoConfig.getIndexDir();
|
||||
indexDir = new File( repoPath, "/" + indexId + "/" );
|
||||
}
|
||||
|
||||
return indexDir;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -20,16 +20,16 @@ package org.apache.maven.archiva.indexer.record;
|
|||
*/
|
||||
|
||||
/**
|
||||
* A repository index record.
|
||||
* A repository content index record.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public interface RepositoryIndexRecord
|
||||
public interface LuceneRepositoryContentRecord
|
||||
{
|
||||
/**
|
||||
* Get the primary key used to identify the record uniquely in the index.
|
||||
*
|
||||
* @return the primary key
|
||||
*/
|
||||
String getPrimaryKey();
|
||||
public String getPrimaryKey();
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.lucene;
|
||||
|
||||
/*
|
||||
* 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 org.apache.lucene.document.DateTools;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.NumberTools;
|
||||
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecord;
|
||||
import org.apache.maven.archiva.indexer.record.StandardArtifactIndexRecord;
|
||||
import org.apache.maven.archiva.indexer.record.StandardIndexRecordFields;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Convert the standard index record to a Lucene document.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class LuceneStandardIndexRecordConverter
|
||||
implements LuceneIndexRecordConverter
|
||||
{
|
||||
public Document convert( RepositoryIndexRecord record )
|
||||
{
|
||||
StandardArtifactIndexRecord rec = (StandardArtifactIndexRecord) record;
|
||||
|
||||
Document document = new Document();
|
||||
addTokenizedField( document, StandardIndexRecordFields.FILENAME, rec.getFilename() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.GROUPID, rec.getGroupId() );
|
||||
addExactField( document, StandardIndexRecordFields.GROUPID_EXACT, rec.getGroupId() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.ARTIFACTID, rec.getArtifactId() );
|
||||
addExactField( document, StandardIndexRecordFields.ARTIFACTID_EXACT, rec.getArtifactId() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.VERSION, rec.getVersion() );
|
||||
addExactField( document, StandardIndexRecordFields.VERSION_EXACT, rec.getVersion() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.BASE_VERSION, rec.getBaseVersion() );
|
||||
addExactField( document, StandardIndexRecordFields.BASE_VERSION_EXACT, rec.getBaseVersion() );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.TYPE, rec.getType() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.CLASSIFIER, rec.getClassifier() );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.PACKAGING, rec.getPackaging() );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.REPOSITORY, rec.getRepository() );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.LAST_MODIFIED,
|
||||
DateTools.timeToString( rec.getLastModified(), DateTools.Resolution.SECOND ) );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.FILE_SIZE, NumberTools.longToString( rec.getSize() ) );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.MD5, rec.getMd5Checksum() );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.SHA1, rec.getSha1Checksum() );
|
||||
if ( rec.getClasses() != null )
|
||||
{
|
||||
addTokenizedField( document, StandardIndexRecordFields.CLASSES,
|
||||
StringUtils.join( rec.getClasses().iterator(), "\n" ) );
|
||||
}
|
||||
if ( rec.getFiles() != null )
|
||||
{
|
||||
addTokenizedField( document, StandardIndexRecordFields.FILES,
|
||||
StringUtils.join( rec.getFiles().iterator(), "\n" ) );
|
||||
}
|
||||
addUntokenizedField( document, StandardIndexRecordFields.PLUGIN_PREFIX, rec.getPluginPrefix() );
|
||||
addUntokenizedField( document, StandardIndexRecordFields.INCEPTION_YEAR, rec.getInceptionYear() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.PROJECT_NAME, rec.getProjectName() );
|
||||
addTokenizedField( document, StandardIndexRecordFields.PROJECT_DESCRIPTION, rec.getProjectDescription() );
|
||||
if ( rec.getDependencies() != null )
|
||||
{
|
||||
addTokenizedField( document, StandardIndexRecordFields.DEPENDENCIES,
|
||||
StringUtils.join( rec.getDependencies().iterator(), "\n" ) );
|
||||
}
|
||||
if ( rec.getDevelopers() != null )
|
||||
{
|
||||
addTokenizedField( document, StandardIndexRecordFields.DEVELOPERS,
|
||||
StringUtils.join( rec.getDevelopers().iterator(), "\n" ) );
|
||||
}
|
||||
/* TODO: add later
|
||||
document.add( Field.Keyword( StandardIndexRecordFields.FLD_LICENSE_URLS, "" ) );
|
||||
document.add( Field.Keyword( StandardIndexRecordFields.FLD_PLUGINS_REPORT, "" ) );
|
||||
document.add( Field.Keyword( StandardIndexRecordFields.FLD_PLUGINS_BUILD, "" ) );
|
||||
*/
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public RepositoryIndexRecord convert( Document document )
|
||||
throws ParseException
|
||||
{
|
||||
StandardArtifactIndexRecord record = new StandardArtifactIndexRecord();
|
||||
|
||||
record.setFilename( document.get( StandardIndexRecordFields.FILENAME ) );
|
||||
record.setGroupId( document.get( StandardIndexRecordFields.GROUPID ) );
|
||||
record.setArtifactId( document.get( StandardIndexRecordFields.ARTIFACTID ) );
|
||||
record.setVersion( document.get( StandardIndexRecordFields.VERSION ) );
|
||||
record.setBaseVersion( document.get( StandardIndexRecordFields.BASE_VERSION ) );
|
||||
record.setType( document.get( StandardIndexRecordFields.TYPE ) );
|
||||
record.setClassifier( document.get( StandardIndexRecordFields.CLASSIFIER ) );
|
||||
record.setPackaging( document.get( StandardIndexRecordFields.PACKAGING ) );
|
||||
record.setRepository( document.get( StandardIndexRecordFields.REPOSITORY ) );
|
||||
record.setLastModified( DateTools.stringToTime( document.get( StandardIndexRecordFields.LAST_MODIFIED ) ) );
|
||||
record.setSize( NumberTools.stringToLong( document.get( StandardIndexRecordFields.FILE_SIZE ) ) );
|
||||
record.setMd5Checksum( document.get( StandardIndexRecordFields.MD5 ) );
|
||||
record.setSha1Checksum( document.get( StandardIndexRecordFields.SHA1 ) );
|
||||
String classes = document.get( StandardIndexRecordFields.CLASSES );
|
||||
if ( classes != null )
|
||||
{
|
||||
record.setClasses( Arrays.asList( classes.split( "\n" ) ) );
|
||||
}
|
||||
String files = document.get( StandardIndexRecordFields.FILES );
|
||||
if ( files != null )
|
||||
{
|
||||
record.setFiles( Arrays.asList( files.split( "\n" ) ) );
|
||||
}
|
||||
String dependencies = document.get( StandardIndexRecordFields.DEPENDENCIES );
|
||||
if ( dependencies != null )
|
||||
{
|
||||
record.setDependencies( Arrays.asList( dependencies.split( "\n" ) ) );
|
||||
}
|
||||
String developers = document.get( StandardIndexRecordFields.DEVELOPERS );
|
||||
if ( developers != null )
|
||||
{
|
||||
record.setDevelopers( Arrays.asList( developers.split( "\n" ) ) );
|
||||
}
|
||||
record.setPluginPrefix( document.get( StandardIndexRecordFields.PLUGIN_PREFIX ) );
|
||||
record.setInceptionYear( document.get( StandardIndexRecordFields.INCEPTION_YEAR ) );
|
||||
record.setProjectName( document.get( StandardIndexRecordFields.PROJECT_NAME ) );
|
||||
record.setProjectDescription( document.get( StandardIndexRecordFields.PROJECT_DESCRIPTION ) );
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
private static void addUntokenizedField( Document document, String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.YES, Field.Index.UN_TOKENIZED ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static void addExactField( Document document, String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.NO, Field.Index.UN_TOKENIZED ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static void addTokenizedField( Document document, String name, String value )
|
||||
{
|
||||
if ( value != null )
|
||||
{
|
||||
document.add( new Field( name, value, Field.Store.YES, Field.Index.TOKENIZED ) );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.apache.maven.archiva.indexer.lucene.analyzers;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.CharTokenizer;
|
||||
import org.apache.maven.archiva.indexer.bytecode.BytecodeKeys;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* Lucene Tokenizer for {@link BytecodeKeys#CLASSES} fields.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ClassnameTokenizer extends CharTokenizer
|
||||
{
|
||||
public ClassnameTokenizer( Reader reader )
|
||||
{
|
||||
super( reader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine Token Character.
|
||||
*
|
||||
* The field is a list of full classnames "com.foo.Object" seperated by
|
||||
* newline characters. "\n".
|
||||
*
|
||||
* Identify newline "\n" and "." as the token delimiters.
|
||||
*/
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return ( ( c != '\n' ) && ( c != '.' ) );
|
||||
}
|
||||
|
||||
/*
|
||||
protected char normalize( char c )
|
||||
{
|
||||
return Character.toLowerCase( c );
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.apache.maven.archiva.indexer.lucene.analyzers;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.CharTokenizer;
|
||||
import org.apache.maven.archiva.indexer.bytecode.BytecodeKeys;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* Lucene Tokenizer for {@link BytecodeKeys#FILES} fields.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FilenamesTokenizer extends CharTokenizer
|
||||
{
|
||||
public FilenamesTokenizer( Reader reader )
|
||||
{
|
||||
super( reader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine Token Character.
|
||||
*
|
||||
* The field is a list of full filenames "/home/archiva/foo/readme.txt" seperated by
|
||||
* newline characters. "\n".
|
||||
*
|
||||
* Identify newline "\n" and "/" as the token delimiters.
|
||||
*/
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return ( ( c != '\n' ) && ( c != '/' ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.apache.maven.archiva.indexer.lucene.analyzers;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.CharTokenizer;
|
||||
import org.apache.maven.archiva.indexer.ArtifactKeys;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* Lucene Tokenizer for {@link ArtifactKeys#GROUPID} fields.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class GroupIdTokenizer extends CharTokenizer
|
||||
{
|
||||
public GroupIdTokenizer( Reader reader )
|
||||
{
|
||||
super( reader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine Token Character.
|
||||
*
|
||||
* The field is a groupId "com.foo.project".
|
||||
*
|
||||
* Identify "." as the token delimiter.
|
||||
*/
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return ( c != '.' );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.apache.maven.archiva.indexer.lucene.analyzers;
|
||||
|
||||
/*
|
||||
* 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.lucene.analysis.CharTokenizer;
|
||||
import org.apache.maven.archiva.indexer.ArtifactKeys;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* Lucene Tokenizer for {@link ArtifactKeys#VERSION} fields.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class VersionTokenizer extends CharTokenizer
|
||||
{
|
||||
public VersionTokenizer( Reader reader )
|
||||
{
|
||||
super( reader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine Token Character.
|
||||
*
|
||||
* The field is a version id in the form "1.0-alpha-4-SNAPSHOT".
|
||||
*
|
||||
* Identify "-" as the token delimiter.
|
||||
*/
|
||||
protected boolean isTokenChar( char c )
|
||||
{
|
||||
return ( c != '.' ) && ( c != '-' );
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.digest.Digester;
|
||||
import org.codehaus.plexus.digest.DigesterException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* Base class for the index record factories.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public abstract class AbstractArtifactIndexRecordFactory
|
||||
extends AbstractLogEnabled
|
||||
implements RepositoryIndexRecordFactory
|
||||
{
|
||||
protected String readChecksum( File file, Digester digester )
|
||||
{
|
||||
String checksum;
|
||||
try
|
||||
{
|
||||
checksum = digester.calc( file ).toLowerCase();
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
getLogger().error( "Error getting checksum for artifact file, leaving empty in index: " + e.getMessage() );
|
||||
checksum = null;
|
||||
}
|
||||
return checksum;
|
||||
}
|
||||
|
||||
protected List readFilesInArchive( File file )
|
||||
throws IOException
|
||||
{
|
||||
ZipFile zipFile = new ZipFile( file );
|
||||
List files;
|
||||
try
|
||||
{
|
||||
files = new ArrayList( zipFile.size() );
|
||||
|
||||
for ( Enumeration entries = zipFile.entries(); entries.hasMoreElements(); )
|
||||
{
|
||||
ZipEntry entry = (ZipEntry) entries.nextElement();
|
||||
|
||||
files.add( entry.getName() );
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( zipFile );
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
protected static boolean isClass( String name )
|
||||
{
|
||||
// TODO: verify if class is public or protected (this might require the original ZipEntry)
|
||||
return name.endsWith( ".class" ) && name.lastIndexOf( "$" ) < 0;
|
||||
}
|
||||
|
||||
protected static void closeQuietly( ZipFile zipFile )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( zipFile != null )
|
||||
{
|
||||
zipFile.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Filter that removes artifacts already in the index.
|
||||
* TODO: we could do timestamp comparisons here
|
||||
*/
|
||||
public class IndexRecordExistsArtifactFilter
|
||||
implements ArtifactFilter
|
||||
{
|
||||
private final Collection keys;
|
||||
|
||||
public IndexRecordExistsArtifactFilter( Collection keys )
|
||||
{
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public boolean include( Artifact artifact )
|
||||
{
|
||||
String artifactKey = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() +
|
||||
( artifact.getClassifier() != null ? ":" + artifact.getClassifier() : "" );
|
||||
return !keys.contains( artifactKey );
|
||||
}
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.List;
|
||||
|
||||
/**
|
||||
* The a record with the fields in the minimal index.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class MinimalArtifactIndexRecord
|
||||
implements RepositoryIndexRecord
|
||||
{
|
||||
/**
|
||||
* The classes in the archive for the artifact, if it is a JAR.
|
||||
*/
|
||||
private List classes;
|
||||
|
||||
/**
|
||||
* The MD5 checksum of the artifact file.
|
||||
*/
|
||||
private String md5Checksum;
|
||||
|
||||
/**
|
||||
* The filename of the artifact file (no path).
|
||||
*/
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* The timestamp that the artifact file was last modified. Granularity is seconds.
|
||||
*/
|
||||
private long lastModified;
|
||||
|
||||
/**
|
||||
* The size of the artifact file in bytes.
|
||||
*/
|
||||
private long size;
|
||||
|
||||
private static final int MS_PER_SEC = 1000;
|
||||
|
||||
public void setClasses( List classes )
|
||||
{
|
||||
this.classes = classes;
|
||||
}
|
||||
|
||||
public void setMd5Checksum( String md5Checksum )
|
||||
{
|
||||
this.md5Checksum = md5Checksum;
|
||||
}
|
||||
|
||||
public void setFilename( String filename )
|
||||
{
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public void setLastModified( long lastModified )
|
||||
{
|
||||
this.lastModified = lastModified - lastModified % MS_PER_SEC;
|
||||
}
|
||||
|
||||
public void setSize( long size )
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public List getClasses()
|
||||
{
|
||||
return classes;
|
||||
}
|
||||
|
||||
public String getMd5Checksum()
|
||||
{
|
||||
return md5Checksum;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
public long getLastModified()
|
||||
{
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
public long getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection RedundantIfStatement
|
||||
*/
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( obj == null || getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MinimalArtifactIndexRecord that = (MinimalArtifactIndexRecord) obj;
|
||||
|
||||
if ( lastModified != that.lastModified )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( size != that.size )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( classes != null ? !classes.equals( that.classes ) : that.classes != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( !filename.equals( that.filename ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( md5Checksum != null ? !md5Checksum.equals( that.md5Checksum ) : that.md5Checksum != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection UnnecessaryParentheses
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
int result = classes != null ? classes.hashCode() : 0;
|
||||
result = 31 * result + ( md5Checksum != null ? md5Checksum.hashCode() : 0 );
|
||||
result = 31 * result + filename.hashCode();
|
||||
result = 31 * result + (int) ( lastModified ^ ( lastModified >>> 32 ) );
|
||||
result = 31 * result + (int) ( size ^ ( size >>> 32 ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Filename: " + filename + "; checksum: " + md5Checksum + "; size: " + size + "; lastModified: " +
|
||||
new Date( lastModified ) + "; classes: " + classes;
|
||||
}
|
||||
|
||||
public String getPrimaryKey()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.artifact.Artifact;
|
||||
import org.codehaus.plexus.digest.Digester;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An index record type for the minimal index.
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
* @author Brett Porter
|
||||
* @plexus.component role="org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory" role-hint="minimal"
|
||||
*/
|
||||
public class MinimalArtifactIndexRecordFactory
|
||||
extends AbstractArtifactIndexRecordFactory
|
||||
{
|
||||
/* List of types to index. */
|
||||
private static final Set INDEXED_TYPES = new HashSet( Arrays.asList( new String[]{"jar", "maven-plugin"} ) );
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="sha1"
|
||||
*/
|
||||
protected Digester sha1Digester;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="md5"
|
||||
*/
|
||||
protected Digester md5Digester;
|
||||
|
||||
public RepositoryIndexRecord createRecord( Artifact artifact )
|
||||
{
|
||||
MinimalArtifactIndexRecord record = null;
|
||||
|
||||
File file = artifact.getFile();
|
||||
if ( file != null && INDEXED_TYPES.contains( artifact.getType() ) && file.exists() )
|
||||
{
|
||||
String md5 = readChecksum( file, md5Digester );
|
||||
|
||||
List files = null;
|
||||
try
|
||||
{
|
||||
files = readFilesInArchive( file );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
getLogger().error( "Error reading artifact file, omitting from index: " + e.getMessage() );
|
||||
}
|
||||
|
||||
if ( files != null )
|
||||
{
|
||||
record = new MinimalArtifactIndexRecord();
|
||||
record.setMd5Checksum( md5 );
|
||||
record.setFilename( artifact.getRepository().pathOf( artifact ) );
|
||||
record.setLastModified( file.lastModified() );
|
||||
record.setSize( file.length() );
|
||||
record.setClasses( getClassesFromFiles( files ) );
|
||||
}
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
private List getClassesFromFiles( List files )
|
||||
{
|
||||
List classes = new ArrayList();
|
||||
|
||||
for ( Iterator i = files.iterator(); i.hasNext(); )
|
||||
{
|
||||
String name = (String) i.next();
|
||||
|
||||
if ( isClass( name ) )
|
||||
{
|
||||
classes.add( name.substring( 0, name.length() - 6 ).replace( '/', '.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The fields in a minimal artifact index record.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @todo should be an enum
|
||||
*/
|
||||
public class MinimalIndexRecordFields
|
||||
{
|
||||
public static final String FILENAME = "j";
|
||||
|
||||
public static final String LAST_MODIFIED = "d";
|
||||
|
||||
public static final String FILE_SIZE = "s";
|
||||
|
||||
public static final String MD5 = "m";
|
||||
|
||||
public static final String CLASSES = "c";
|
||||
|
||||
private MinimalIndexRecordFields()
|
||||
{
|
||||
// No touchy!
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
/**
|
||||
* The layout of a record in a repository index.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public interface RepositoryIndexRecordFactory
|
||||
{
|
||||
/**
|
||||
* The Plexus role.
|
||||
*/
|
||||
String ROLE = RepositoryIndexRecordFactory.class.getName();
|
||||
|
||||
/**
|
||||
* Create an index record from an artifact.
|
||||
*
|
||||
* @param artifact the artifact
|
||||
* @return the index record
|
||||
* @throws RepositoryIndexException if there is a problem constructing the record (due to not being able to read the artifact file as a POM)
|
||||
*/
|
||||
RepositoryIndexRecord createRecord( Artifact artifact )
|
||||
throws RepositoryIndexException;
|
||||
|
||||
}
|
|
@ -1,412 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The a record with the fields in the standard index.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class StandardArtifactIndexRecord
|
||||
extends MinimalArtifactIndexRecord
|
||||
{
|
||||
/**
|
||||
* The SHA-1 checksum of the artifact file.
|
||||
*/
|
||||
private String sha1Checksum;
|
||||
|
||||
/**
|
||||
* The artifact's group.
|
||||
*/
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
* The artifact's identifier within the group.
|
||||
*/
|
||||
private String artifactId;
|
||||
|
||||
/**
|
||||
* The artifact's version.
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* The classifier, if there is one.
|
||||
*/
|
||||
private String classifier;
|
||||
|
||||
/**
|
||||
* The artifact type (from the file).
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* A list of files (separated by '\n') in the artifact if it is an archive.
|
||||
*/
|
||||
private List files;
|
||||
|
||||
/**
|
||||
* The identifier of the repository that the artifact came from.
|
||||
*/
|
||||
private String repository;
|
||||
|
||||
/**
|
||||
* The packaging specified in the POM for this artifact.
|
||||
*/
|
||||
private String packaging;
|
||||
|
||||
/**
|
||||
* The plugin prefix specified in the metadata if the artifact is a plugin.
|
||||
*/
|
||||
private String pluginPrefix;
|
||||
|
||||
/**
|
||||
* The year the project was started.
|
||||
*/
|
||||
private String inceptionYear;
|
||||
|
||||
/**
|
||||
* The description of the project.
|
||||
*/
|
||||
private String projectDescription;
|
||||
|
||||
/**
|
||||
* The name of the project.
|
||||
*/
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* The base version (before the snapshot is determined).
|
||||
*/
|
||||
private String baseVersion;
|
||||
|
||||
/**
|
||||
* A list of dependencies for the artifact, each a string of the form <code>groupId:artifactId:version</code>.
|
||||
*/
|
||||
private List dependencies;
|
||||
|
||||
/**
|
||||
* A list of developers in the POM, each a string of the form <code>id:name:email</code>.
|
||||
*/
|
||||
private List developers;
|
||||
|
||||
public void setSha1Checksum( String sha1Checksum )
|
||||
{
|
||||
this.sha1Checksum = sha1Checksum;
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setClassifier( String classifier )
|
||||
{
|
||||
this.classifier = classifier;
|
||||
}
|
||||
|
||||
public void setType( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setFiles( List files )
|
||||
{
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public void setRepository( String repository )
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection RedundantIfStatement
|
||||
*/
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( obj == null || getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( !super.equals( obj ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
StandardArtifactIndexRecord that = (StandardArtifactIndexRecord) obj;
|
||||
|
||||
if ( !artifactId.equals( that.artifactId ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( dependencies != null && that.dependencies != null )
|
||||
{
|
||||
List sorted = new ArrayList( dependencies );
|
||||
Collections.sort( sorted );
|
||||
|
||||
List sortedOther = new ArrayList( that.dependencies );
|
||||
Collections.sort( sortedOther );
|
||||
|
||||
if ( !sorted.equals( sortedOther ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( !( dependencies == null && that.dependencies == null ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( developers != null ? !developers.equals( that.developers ) : that.developers != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( files != null ? !files.equals( that.files ) : that.files != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( !groupId.equals( that.groupId ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( repository != null ? !repository.equals( that.repository ) : that.repository != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( sha1Checksum != null ? !sha1Checksum.equals( that.sha1Checksum ) : that.sha1Checksum != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( type != null ? !type.equals( that.type ) : that.type != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( !version.equals( that.version ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( !baseVersion.equals( that.baseVersion ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( pluginPrefix != null ? !pluginPrefix.equals( that.pluginPrefix ) : that.pluginPrefix != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( projectName != null ? !projectName.equals( that.projectName ) : that.projectName != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( inceptionYear != null ? !inceptionYear.equals( that.inceptionYear ) : that.inceptionYear != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( projectDescription != null ? !projectDescription.equals( that.projectDescription )
|
||||
: that.projectDescription != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + ( sha1Checksum != null ? sha1Checksum.hashCode() : 0 );
|
||||
result = 31 * result + groupId.hashCode();
|
||||
result = 31 * result + artifactId.hashCode();
|
||||
result = 31 * result + version.hashCode();
|
||||
result = 31 * result + baseVersion.hashCode();
|
||||
result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
|
||||
result = 31 * result + ( type != null ? type.hashCode() : 0 );
|
||||
result = 31 * result + ( files != null ? files.hashCode() : 0 );
|
||||
result = 31 * result + ( developers != null ? developers.hashCode() : 0 );
|
||||
|
||||
if ( dependencies != null )
|
||||
{
|
||||
List sorted = new ArrayList( dependencies );
|
||||
Collections.sort( sorted );
|
||||
|
||||
result = 31 * result + sorted.hashCode();
|
||||
}
|
||||
|
||||
result = 31 * result + ( repository != null ? repository.hashCode() : 0 );
|
||||
result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
|
||||
result = 31 * result + ( pluginPrefix != null ? pluginPrefix.hashCode() : 0 );
|
||||
result = 31 * result + ( inceptionYear != null ? inceptionYear.hashCode() : 0 );
|
||||
result = 31 * result + ( projectName != null ? projectName.hashCode() : 0 );
|
||||
result = 31 * result + ( projectDescription != null ? projectDescription.hashCode() : 0 );
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getSha1Checksum()
|
||||
{
|
||||
return sha1Checksum;
|
||||
}
|
||||
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getClassifier()
|
||||
{
|
||||
return classifier;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public List getFiles()
|
||||
{
|
||||
return files;
|
||||
}
|
||||
|
||||
public String getRepository()
|
||||
{
|
||||
return repository;
|
||||
}
|
||||
|
||||
public String getPackaging()
|
||||
{
|
||||
return packaging;
|
||||
}
|
||||
|
||||
public String getPluginPrefix()
|
||||
{
|
||||
return pluginPrefix;
|
||||
}
|
||||
|
||||
public void setPackaging( String packaging )
|
||||
{
|
||||
this.packaging = packaging;
|
||||
}
|
||||
|
||||
public void setPluginPrefix( String pluginPrefix )
|
||||
{
|
||||
this.pluginPrefix = pluginPrefix;
|
||||
}
|
||||
|
||||
public void setInceptionYear( String inceptionYear )
|
||||
{
|
||||
this.inceptionYear = inceptionYear;
|
||||
}
|
||||
|
||||
public void setProjectDescription( String description )
|
||||
{
|
||||
this.projectDescription = description;
|
||||
}
|
||||
|
||||
public void setProjectName( String projectName )
|
||||
{
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getInceptionYear()
|
||||
{
|
||||
return inceptionYear;
|
||||
}
|
||||
|
||||
public String getProjectDescription()
|
||||
{
|
||||
return projectDescription;
|
||||
}
|
||||
|
||||
public String getProjectName()
|
||||
{
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setBaseVersion( String baseVersion )
|
||||
{
|
||||
this.baseVersion = baseVersion;
|
||||
}
|
||||
|
||||
public String getBaseVersion()
|
||||
{
|
||||
return baseVersion;
|
||||
}
|
||||
|
||||
public void setDependencies( List dependencies )
|
||||
{
|
||||
this.dependencies = dependencies;
|
||||
}
|
||||
|
||||
public void setDevelopers( List developers )
|
||||
{
|
||||
this.developers = developers;
|
||||
}
|
||||
|
||||
public List getDevelopers()
|
||||
{
|
||||
return developers;
|
||||
}
|
||||
|
||||
public List getDependencies()
|
||||
{
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public String getPrimaryKey()
|
||||
{
|
||||
return groupId + ":" + artifactId + ":" + version + ( classifier != null ? ":" + classifier : "" );
|
||||
}
|
||||
}
|
|
@ -1,373 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Developer;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.digest.Digester;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* An index record type for the standard index.
|
||||
*
|
||||
* @author Edwin Punzalan
|
||||
* @author Brett Porter
|
||||
* @plexus.component role="org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory" role-hint="standard"
|
||||
*/
|
||||
public class StandardArtifactIndexRecordFactory
|
||||
extends AbstractArtifactIndexRecordFactory
|
||||
{
|
||||
/**
|
||||
* A list of artifact types to treat as a zip archive.
|
||||
*
|
||||
* @todo this should be smarter (perhaps use plexus archiver to look for an unarchiver, and make the ones for zip configurable since sar, par, etc can be added at random.
|
||||
*/
|
||||
private static final Set ARCHIVE_TYPES =
|
||||
new HashSet( Arrays.asList( new String[]{"jar", "ejb", "par", "sar", "war", "ear", "rar"} ) );
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private MavenProjectBuilder projectBuilder;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="sha1"
|
||||
*/
|
||||
protected Digester sha1Digester;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="md5"
|
||||
*/
|
||||
protected Digester md5Digester;
|
||||
|
||||
private static final String SITE_TEMPLATE_NAME = "META-INF/maven/site.vm";
|
||||
|
||||
private static final String SITE_CSS_NAME = "css/maven-theme.css";
|
||||
|
||||
private static final String PLUGIN_METADATA_NAME = "META-INF/maven/plugin.xml";
|
||||
|
||||
private static final String ARCHETYPE_METADATA_NAME = "META-INF/maven/archetype.xml";
|
||||
|
||||
// some current/old archetypes have the archetype.xml at different location.
|
||||
private static final String ARCHETYPE_METADATA_NAME_OLD = "META-INF/archetype.xml";
|
||||
|
||||
public RepositoryIndexRecord createRecord( Artifact artifact )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
StandardArtifactIndexRecord record = null;
|
||||
|
||||
File file = artifact.getFile();
|
||||
|
||||
// TODO: is this condition really a possibility?
|
||||
if ( file != null && file.exists() )
|
||||
{
|
||||
String md5 = readChecksum( file, md5Digester );
|
||||
String sha1 = readChecksum( file, sha1Digester );
|
||||
|
||||
List files = null;
|
||||
boolean archive = ARCHIVE_TYPES.contains( artifact.getType() );
|
||||
try
|
||||
{
|
||||
if ( archive )
|
||||
{
|
||||
files = readFilesInArchive( file );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
getLogger().error( "Error reading artifact file, omitting from index: " + e.getMessage() );
|
||||
}
|
||||
|
||||
// If it's an archive with no files, don't create a record
|
||||
if ( !archive || files != null )
|
||||
{
|
||||
record = new StandardArtifactIndexRecord();
|
||||
|
||||
record.setGroupId( artifact.getGroupId() );
|
||||
record.setArtifactId( artifact.getArtifactId() );
|
||||
record.setBaseVersion( artifact.getBaseVersion() );
|
||||
record.setVersion( artifact.getVersion() );
|
||||
record.setClassifier( artifact.getClassifier() );
|
||||
record.setType( artifact.getType() );
|
||||
record.setMd5Checksum( md5 );
|
||||
record.setSha1Checksum( sha1 );
|
||||
record.setFilename( artifact.getRepository().pathOf( artifact ) );
|
||||
record.setLastModified( file.lastModified() );
|
||||
record.setSize( file.length() );
|
||||
record.setRepository( artifact.getRepository().getId() );
|
||||
|
||||
if ( files != null )
|
||||
{
|
||||
populateArchiveEntries( files, record, artifact.getFile() );
|
||||
}
|
||||
|
||||
if ( !"pom".equals( artifact.getType() ) )
|
||||
{
|
||||
Artifact pomArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(),
|
||||
artifact.getArtifactId(),
|
||||
artifact.getVersion() );
|
||||
pomArtifact.isSnapshot(); // gross hack around bug in maven-artifact
|
||||
File pomFile = new File( artifact.getRepository().getBasedir(),
|
||||
artifact.getRepository().pathOf( pomArtifact ) );
|
||||
if ( pomFile.exists() )
|
||||
{
|
||||
try
|
||||
{
|
||||
populatePomEntries( readPom( pomArtifact, artifact.getRepository() ), record );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
getLogger().error( "Error reading POM file [" + pomFile + "] for " + artifact +
|
||||
", not populating in index: " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Model model;
|
||||
try
|
||||
{
|
||||
model = readPom( artifact, artifact.getRepository() );
|
||||
|
||||
if ( !"pom".equals( model.getPackaging() ) )
|
||||
{
|
||||
// Don't return a record for a POM that is does not belong on its own
|
||||
record = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
populatePomEntries( model, record );
|
||||
}
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
getLogger().error(
|
||||
"Error reading POM file for " + artifact + ", not populating in index: " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
private void populatePomEntries( Model pom, StandardArtifactIndexRecord record )
|
||||
{
|
||||
record.setPackaging( pom.getPackaging() );
|
||||
record.setProjectName( pom.getName() );
|
||||
record.setProjectDescription( pom.getDescription() );
|
||||
record.setInceptionYear( pom.getInceptionYear() );
|
||||
|
||||
List dependencies = populateDependencies( pom.getDependencies() );
|
||||
if ( !dependencies.isEmpty() )
|
||||
{
|
||||
record.setDependencies( dependencies );
|
||||
}
|
||||
List developers = populateDevelopers( pom.getDevelopers() );
|
||||
if ( !developers.isEmpty() )
|
||||
{
|
||||
record.setDevelopers( developers );
|
||||
}
|
||||
|
||||
/* TODO: fields for later
|
||||
indexPlugins( doc, FLD_PLUGINS_BUILD, pom.getBuild().getPlugins().iterator() );
|
||||
indexReportPlugins( doc, FLD_PLUGINS_REPORT, pom.getReporting().getPlugins().iterator() );
|
||||
record.setLicenses( licenses );
|
||||
*/
|
||||
}
|
||||
|
||||
private List populateDependencies( List dependencies )
|
||||
{
|
||||
List convertedDependencies = new ArrayList();
|
||||
|
||||
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency dependency = (Dependency) i.next();
|
||||
|
||||
convertedDependencies.add(
|
||||
dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() );
|
||||
}
|
||||
|
||||
return convertedDependencies;
|
||||
}
|
||||
|
||||
private List populateDevelopers( List developers )
|
||||
{
|
||||
List convertedDevelopers = new ArrayList();
|
||||
|
||||
for ( Iterator i = developers.iterator(); i.hasNext(); )
|
||||
{
|
||||
Developer developer = (Developer) i.next();
|
||||
|
||||
convertedDevelopers.add( developer.getId() + ":" + developer.getName() + ":" + developer.getEmail() );
|
||||
}
|
||||
|
||||
return convertedDevelopers;
|
||||
}
|
||||
|
||||
private Model readPom( Artifact artifact, ArtifactRepository repository )
|
||||
throws RepositoryIndexException, ProjectBuildingException
|
||||
{
|
||||
// TODO: this can create a -SNAPSHOT.pom when it didn't exist and a timestamped one did. This is harmless, but should be avoided
|
||||
// TODO: will this pollute with local repo metadata?
|
||||
|
||||
try
|
||||
{
|
||||
MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository );
|
||||
return project.getModel();
|
||||
}
|
||||
catch ( InvalidArtifactRTException e )
|
||||
{
|
||||
throw new ProjectBuildingException( artifact.getId(),
|
||||
"Unable to build project from invalid artifact [" + artifact + "]", e );
|
||||
}
|
||||
}
|
||||
|
||||
private void populateArchiveEntries( List files, StandardArtifactIndexRecord record, File artifactFile )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
List classes = new ArrayList();
|
||||
List fileList = new ArrayList();
|
||||
|
||||
for ( Iterator i = files.iterator(); i.hasNext(); )
|
||||
{
|
||||
String name = (String) i.next();
|
||||
|
||||
// ignore directories
|
||||
if ( !name.endsWith( "/" ) )
|
||||
{
|
||||
fileList.add( name );
|
||||
|
||||
if ( isClass( name ) )
|
||||
{
|
||||
classes.add( name.substring( 0, name.length() - 6 ).replace( '/', '.' ) );
|
||||
}
|
||||
else if ( PLUGIN_METADATA_NAME.equals( name ) )
|
||||
{
|
||||
populatePluginEntries( readXmlMetadataFileInJar( artifactFile, PLUGIN_METADATA_NAME ), record );
|
||||
}
|
||||
else if ( ARCHETYPE_METADATA_NAME.equals( name ) || ARCHETYPE_METADATA_NAME_OLD.equals( name ) )
|
||||
{
|
||||
populateArchetypeEntries( record );
|
||||
}
|
||||
else if ( SITE_TEMPLATE_NAME.equals( name ) || SITE_CSS_NAME.equals( name ) )
|
||||
{
|
||||
populateSkinEntries( record );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !classes.isEmpty() )
|
||||
{
|
||||
record.setClasses( classes );
|
||||
}
|
||||
if ( !fileList.isEmpty() )
|
||||
{
|
||||
record.setFiles( fileList );
|
||||
}
|
||||
}
|
||||
|
||||
private void populateArchetypeEntries( StandardArtifactIndexRecord record )
|
||||
{
|
||||
// Typically discovered as a JAR
|
||||
record.setType( "maven-archetype" );
|
||||
}
|
||||
|
||||
private void populateSkinEntries( StandardArtifactIndexRecord record )
|
||||
{
|
||||
// Typically discovered as a JAR
|
||||
record.setType( "maven-skin" );
|
||||
}
|
||||
|
||||
private Xpp3Dom readXmlMetadataFileInJar( File file, String name )
|
||||
throws RepositoryIndexException
|
||||
{
|
||||
// TODO: would be more efficient with original ZipEntry still around
|
||||
|
||||
Xpp3Dom xpp3Dom;
|
||||
ZipFile zipFile = null;
|
||||
try
|
||||
{
|
||||
zipFile = new ZipFile( file );
|
||||
ZipEntry entry = zipFile.getEntry( name );
|
||||
xpp3Dom = Xpp3DomBuilder.build( new InputStreamReader( zipFile.getInputStream( entry ) ) );
|
||||
}
|
||||
catch ( ZipException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Unable to read plugin metadata: " + e.getMessage(), e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Unable to read plugin metadata: " + e.getMessage(), e );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new RepositoryIndexException( "Unable to read plugin metadata: " + e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly( zipFile );
|
||||
}
|
||||
return xpp3Dom;
|
||||
}
|
||||
|
||||
public void populatePluginEntries( Xpp3Dom metadata, StandardArtifactIndexRecord record )
|
||||
{
|
||||
// Typically discovered as a JAR
|
||||
record.setType( "maven-plugin" );
|
||||
|
||||
Xpp3Dom prefix = metadata.getChild( "goalPrefix" );
|
||||
|
||||
if ( prefix != null )
|
||||
{
|
||||
record.setPluginPrefix( prefix.getValue() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package org.apache.maven.archiva.indexer.record;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The fields in a minimal artifact index record.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @todo should be an enum
|
||||
*/
|
||||
public class StandardIndexRecordFields
|
||||
{
|
||||
public static final String FILENAME = "filename";
|
||||
|
||||
public static final String GROUPID = "groupId";
|
||||
|
||||
public static final String GROUPID_EXACT = GROUPID + "_u";
|
||||
|
||||
public static final String ARTIFACTID = "artifactId";
|
||||
|
||||
public static final String ARTIFACTID_EXACT = ARTIFACTID + "_u";
|
||||
|
||||
public static final String VERSION = "version";
|
||||
|
||||
public static final String VERSION_EXACT = VERSION + "_u";
|
||||
|
||||
public static final String BASE_VERSION = "baseVersion";
|
||||
|
||||
public static final String BASE_VERSION_EXACT = BASE_VERSION + "_u";
|
||||
|
||||
public static final String TYPE = "type";
|
||||
|
||||
public static final String CLASSIFIER = "classifier";
|
||||
|
||||
public static final String PACKAGING = "packaging";
|
||||
|
||||
public static final String REPOSITORY = "repo";
|
||||
|
||||
public static final String LAST_MODIFIED = "lastModified";
|
||||
|
||||
public static final String FILE_SIZE = "fileSize";
|
||||
|
||||
public static final String MD5 = "md5";
|
||||
|
||||
public static final String SHA1 = "sha1";
|
||||
|
||||
public static final String CLASSES = "classes";
|
||||
|
||||
public static final String PLUGIN_PREFIX = "pluginPrefix";
|
||||
|
||||
public static final String FILES = "files";
|
||||
|
||||
public static final String INCEPTION_YEAR = "inceptionYear";
|
||||
|
||||
public static final String PROJECT_NAME = "projectName";
|
||||
|
||||
public static final String PROJECT_DESCRIPTION = "projectDesc";
|
||||
|
||||
public static final String DEVELOPERS = "developers";
|
||||
|
||||
public static final String DEPENDENCIES = "dependencies";
|
||||
|
||||
private StandardIndexRecordFields()
|
||||
{
|
||||
// No touchy!
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
FILENAME|archiva-common-1.0-SNAPSHOT.jar
|
||||
SIZE|8516
|
||||
HASH_MD5|a5d0d280ce83133432d8fed8f2ce3474
|
||||
HASH_SHA1|c2635a1b38bd4520a6604664c04b2b3c32330864
|
||||
HASH_BYTECODE|2868f6661c55afda5a3b62859fbc8b1beb021b6e
|
||||
JDK|1.4
|
||||
CLASS|org.apache.maven.archiva.common.ArchivaException
|
||||
CLASS|org.apache.maven.archiva.common.utils.BaseFile
|
||||
CLASS|org.apache.maven.archiva.common.utils.DateUtil
|
||||
CLASS|org.apache.maven.archiva.common.utils.PathUtil
|
||||
CLASS|org.apache.maven.archiva.common.utils.VersionUtil
|
||||
METHOD|org.apache.maven.archiva.common.ArchivaException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.archiva.common.ArchivaException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/io/File;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/lang/String;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/lang/String;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/net/URI;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.getBaseDir()Ljava/io/File;
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.getRelativePath()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.setBaseDir(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.setBaseDir(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.BaseFile.class$(Ljava/lang/String;)Ljava/lang/Class;
|
||||
METHOD|org.apache.maven.archiva.common.utils.DateUtil.<init>()V
|
||||
METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(J)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(JJ)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(Ljava/util/Date;Ljava/util/Date;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(Ljava/util/Calendar;Ljava/util/Calendar;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.DateUtil.appendInterval(Ljava/lang/StringBuffer;ILjava/lang/String;)V
|
||||
METHOD|org.apache.maven.archiva.common.utils.PathUtil.<init>()V
|
||||
METHOD|org.apache.maven.archiva.common.utils.PathUtil.getRelative(Ljava/lang/String;Ljava/io/File;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.PathUtil.getRelative(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.VersionUtil.<init>()V
|
||||
METHOD|org.apache.maven.archiva.common.utils.VersionUtil.isSnapshot(Ljava/lang/String;)Z
|
||||
METHOD|org.apache.maven.archiva.common.utils.VersionUtil.getBaseVersion(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.archiva.common.utils.VersionUtil.<clinit>()V
|
||||
FILE|META-INF/
|
||||
FILE|META-INF/MANIFEST.MF
|
||||
FILE|META-INF/maven/
|
||||
FILE|META-INF/maven/org.apache.maven.archiva/
|
||||
FILE|META-INF/maven/org.apache.maven.archiva/archiva-common/
|
||||
FILE|META-INF/maven/org.apache.maven.archiva/archiva-common/pom.properties
|
||||
FILE|META-INF/maven/org.apache.maven.archiva/archiva-common/pom.xml
|
||||
FILE|org/
|
||||
FILE|org/apache/
|
||||
FILE|org/apache/maven/
|
||||
FILE|org/apache/maven/archiva/
|
||||
FILE|org/apache/maven/archiva/common/
|
||||
FILE|org/apache/maven/archiva/common/ArchivaException.class
|
||||
FILE|org/apache/maven/archiva/common/utils/
|
||||
FILE|org/apache/maven/archiva/common/utils/BaseFile.class
|
||||
FILE|org/apache/maven/archiva/common/utils/DateUtil.class
|
||||
FILE|org/apache/maven/archiva/common/utils/PathUtil.class
|
||||
FILE|org/apache/maven/archiva/common/utils/VersionUtil.class
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
FILENAME|daytrader-ear-1.1.ear
|
||||
SIZE|1005420
|
||||
HASH_MD5|4d677e8e95fb342512e3d05ea68a501d
|
||||
HASH_SHA1|58f1e8ae41f12747947c947437e262d9f3bd3ce7
|
||||
HASH_BYTECODE|
|
||||
JDK|1.0
|
||||
FILE|META-INF/
|
||||
FILE|META-INF/MANIFEST.MF
|
||||
FILE|META-INF/application.xml
|
||||
FILE|META-INF/maven/
|
||||
FILE|META-INF/maven/geronimo/
|
||||
FILE|META-INF/maven/geronimo/daytrader-ear/
|
||||
FILE|META-INF/maven/geronimo/daytrader-ear/pom.properties
|
||||
FILE|META-INF/maven/geronimo/daytrader-ear/pom.xml
|
||||
FILE|dt-ejb.jar
|
||||
FILE|streamer.jar
|
||||
FILE|web.war
|
||||
FILE|wsappclient.jar
|
|
@ -0,0 +1,19 @@
|
|||
FILENAME|maven-archetype-simple-1.0-alpha-4.jar
|
||||
SIZE|4451
|
||||
HASH_MD5|446c23f1e3f88f2dd2d490f8492f65dc
|
||||
HASH_SHA1|a9a5b26651836425dacd77fa3646701dff648e14
|
||||
HASH_BYTECODE|734edd1419ea3e792e7c15b22b1d823947c43e5a
|
||||
JDK|1.1
|
||||
CLASS|archetype.App
|
||||
METHOD|archetype.App.<init>()V
|
||||
METHOD|archetype.App.main([Ljava/lang/String;)V
|
||||
FILE|META-INF/
|
||||
FILE|META-INF/MANIFEST.MF
|
||||
FILE|META-INF/maven/
|
||||
FILE|META-INF/maven/org.apache.maven.archetypes/
|
||||
FILE|META-INF/maven/org.apache.maven.archetypes/maven-archetype-simple/
|
||||
FILE|META-INF/maven/org.apache.maven.archetypes/maven-archetype-simple/pom.properties
|
||||
FILE|META-INF/maven/org.apache.maven.archetypes/maven-archetype-simple/pom.xml
|
||||
FILE|app.properties
|
||||
FILE|archetype/
|
||||
FILE|archetype/App.class
|
|
@ -0,0 +1,88 @@
|
|||
FILENAME|maven-help-plugin-2.0.2-20070119.121239-2.jar
|
||||
SIZE|20741
|
||||
HASH_MD5|16b9374e2f36e42978880b62dce34a0a
|
||||
HASH_SHA1|dc87f75ac4ba9c63066372ffae9830e42648f829
|
||||
HASH_BYTECODE|c4495d02a84259a458b13023d935efd8c33fcf33
|
||||
JDK|1.1
|
||||
CLASS|org.apache.maven.plugins.help.ActiveProfilesMojo
|
||||
CLASS|org.apache.maven.plugins.help.DependenciesMojo
|
||||
CLASS|org.apache.maven.plugins.help.DescribeMojo$1
|
||||
CLASS|org.apache.maven.plugins.help.DescribeMojo$PluginInfo
|
||||
CLASS|org.apache.maven.plugins.help.DescribeMojo
|
||||
CLASS|org.apache.maven.plugins.help.EffectivePomMojo
|
||||
CLASS|org.apache.maven.plugins.help.EffectiveSettingsMojo
|
||||
METHOD|org.apache.maven.plugins.help.ActiveProfilesMojo.<init>()V
|
||||
METHOD|org.apache.maven.plugins.help.ActiveProfilesMojo.execute()V
|
||||
METHOD|org.apache.maven.plugins.help.ActiveProfilesMojo.writeFile(Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.ActiveProfilesMojo.getActiveProfileStatement(Lorg/apache/maven/project/MavenProject;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.ActiveProfilesMojo.setProjects(Ljava/util/List;)V
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.<init>()V
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.execute()V
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.serialiseDependencyTree(Lorg/apache/maven/shared/dependency/tree/DependencyTree;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.serialiseDependencyNode(Lorg/apache/maven/shared/dependency/tree/DependencyNode;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.write(Ljava/lang/String;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.log(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.DependenciesMojo.<clinit>()V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo$PluginInfo.<init>()V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo$PluginInfo.<init>(Lorg/apache/maven/plugins/help/DescribeMojo$1;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.<init>()V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.execute()V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.writeDescription(Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.lookupPluginDescriptor(Lorg/apache/maven/plugins/help/DescribeMojo$PluginInfo;)Lorg/apache/maven/plugin/descriptor/PluginDescriptor;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.parsePluginLookupInfo(Lorg/apache/maven/plugins/help/DescribeMojo$PluginInfo;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.describePlugin(Lorg/apache/maven/plugin/descriptor/PluginDescriptor;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.formatDescription(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.prettyAppend(Ljava/lang/String;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.describeMojo(Lorg/apache/maven/plugin/descriptor/MojoDescriptor;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.describeMojoGuts(Lorg/apache/maven/plugin/descriptor/MojoDescriptor;Ljava/lang/StringBuffer;Z)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.describeMojoRequirements(Lorg/apache/maven/plugin/descriptor/MojoDescriptor;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.describeMojoParameters(Lorg/apache/maven/plugin/descriptor/MojoDescriptor;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getPlugin()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setPlugin(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getPluginManager()Lorg/apache/maven/plugin/PluginManager;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setPluginManager(Lorg/apache/maven/plugin/PluginManager;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getArtifactId()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setArtifactId(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getGroupId()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setGroupId(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getLocalRepository()Lorg/apache/maven/artifact/repository/ArtifactRepository;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setLocalRepository(Lorg/apache/maven/artifact/repository/ArtifactRepository;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getMojo()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setMojo(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getOutput()Ljava/io/File;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setOutput(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getProject()Lorg/apache/maven/project/MavenProject;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setProject(Lorg/apache/maven/project/MavenProject;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getSettings()Lorg/apache/maven/settings/Settings;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setSettings(Lorg/apache/maven/settings/Settings;)V
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.getVersion()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.plugins.help.DescribeMojo.setVersion(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.EffectivePomMojo.<init>()V
|
||||
METHOD|org.apache.maven.plugins.help.EffectivePomMojo.execute()V
|
||||
METHOD|org.apache.maven.plugins.help.EffectivePomMojo.getEffectivePom(Lorg/apache/maven/project/MavenProject;Ljava/lang/StringBuffer;)V
|
||||
METHOD|org.apache.maven.plugins.help.EffectivePomMojo.setOutput(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.plugins.help.EffectivePomMojo.setProjects(Ljava/util/List;)V
|
||||
METHOD|org.apache.maven.plugins.help.EffectiveSettingsMojo.<init>()V
|
||||
METHOD|org.apache.maven.plugins.help.EffectiveSettingsMojo.execute()V
|
||||
METHOD|org.apache.maven.plugins.help.EffectiveSettingsMojo.setOutput(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.plugins.help.EffectiveSettingsMojo.setSettings(Lorg/apache/maven/settings/Settings;)V
|
||||
FILE|META-INF/
|
||||
FILE|META-INF/MANIFEST.MF
|
||||
FILE|META-INF/maven/
|
||||
FILE|META-INF/maven/org.apache.maven.plugins/
|
||||
FILE|META-INF/maven/org.apache.maven.plugins/maven-help-plugin/
|
||||
FILE|META-INF/maven/org.apache.maven.plugins/maven-help-plugin/pom.properties
|
||||
FILE|META-INF/maven/org.apache.maven.plugins/maven-help-plugin/pom.xml
|
||||
FILE|META-INF/maven/plugin.xml
|
||||
FILE|org/
|
||||
FILE|org/apache/
|
||||
FILE|org/apache/maven/
|
||||
FILE|org/apache/maven/plugins/
|
||||
FILE|org/apache/maven/plugins/help/
|
||||
FILE|org/apache/maven/plugins/help/ActiveProfilesMojo.class
|
||||
FILE|org/apache/maven/plugins/help/DependenciesMojo.class
|
||||
FILE|org/apache/maven/plugins/help/DescribeMojo$1.class
|
||||
FILE|org/apache/maven/plugins/help/DescribeMojo$PluginInfo.class
|
||||
FILE|org/apache/maven/plugins/help/DescribeMojo.class
|
||||
FILE|org/apache/maven/plugins/help/EffectivePomMojo.class
|
||||
FILE|org/apache/maven/plugins/help/EffectiveSettingsMojo.class
|
|
@ -0,0 +1,26 @@
|
|||
FILENAME|redback-authorization-open-1.0-alpha-1-SNAPSHOT.jar
|
||||
SIZE|4080
|
||||
HASH_MD5|f42047fe2e177ac04d0df7aa44d408be
|
||||
HASH_SHA1|2bb14b388973351b0a4dfe11d171965f59cc61a1
|
||||
HASH_BYTECODE|817c08abe3d48d67a5c49c13e7c5497da7bd5e8e
|
||||
JDK|1.4
|
||||
CLASS|org.codehaus.plexus.redback.authorization.open.OpenAuthorizer
|
||||
METHOD|org.codehaus.plexus.redback.authorization.open.OpenAuthorizer.<init>()V
|
||||
METHOD|org.codehaus.plexus.redback.authorization.open.OpenAuthorizer.getId()Ljava/lang/String;
|
||||
METHOD|org.codehaus.plexus.redback.authorization.open.OpenAuthorizer.isAuthorized(Lorg/codehaus/plexus/redback/authorization/AuthorizationDataSource;)Lorg/codehaus/plexus/redback/authorization/AuthorizationResult;
|
||||
FILE|META-INF/
|
||||
FILE|META-INF/MANIFEST.MF
|
||||
FILE|META-INF/maven/
|
||||
FILE|META-INF/maven/org.codehaus.plexus.redback/
|
||||
FILE|META-INF/maven/org.codehaus.plexus.redback/redback-authorization-open/
|
||||
FILE|META-INF/maven/org.codehaus.plexus.redback/redback-authorization-open/pom.properties
|
||||
FILE|META-INF/maven/org.codehaus.plexus.redback/redback-authorization-open/pom.xml
|
||||
FILE|META-INF/plexus/
|
||||
FILE|META-INF/plexus/components.xml
|
||||
FILE|org/
|
||||
FILE|org/codehaus/
|
||||
FILE|org/codehaus/plexus/
|
||||
FILE|org/codehaus/plexus/redback/
|
||||
FILE|org/codehaus/plexus/redback/authorization/
|
||||
FILE|org/codehaus/plexus/redback/authorization/open/
|
||||
FILE|org/codehaus/plexus/redback/authorization/open/OpenAuthorizer.class
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,435 @@
|
|||
FILENAME|wagon-provider-api-1.0-beta-3-20070209.213958-2.jar
|
||||
SIZE|43527
|
||||
HASH_MD5|51e8109f78e663f11310f7df2790dbce
|
||||
HASH_SHA1|7a8322eff673ed8f8d79b4676aca0d7d2004241d
|
||||
HASH_BYTECODE|edde91be8d27eef6ee0da42147bb313af891871a
|
||||
JDK|1.1
|
||||
CLASS|org.apache.maven.wagon.AbstractWagon
|
||||
CLASS|org.apache.maven.wagon.CommandExecutionException
|
||||
CLASS|org.apache.maven.wagon.CommandExecutor$1
|
||||
CLASS|org.apache.maven.wagon.CommandExecutor
|
||||
CLASS|org.apache.maven.wagon.ConnectionException
|
||||
CLASS|org.apache.maven.wagon.InputData
|
||||
CLASS|org.apache.maven.wagon.LazyFileOutputStream
|
||||
CLASS|org.apache.maven.wagon.OutputData
|
||||
CLASS|org.apache.maven.wagon.PathUtils
|
||||
CLASS|org.apache.maven.wagon.PermissionModeUtils
|
||||
CLASS|org.apache.maven.wagon.ResourceDoesNotExistException
|
||||
CLASS|org.apache.maven.wagon.StreamWagon
|
||||
CLASS|org.apache.maven.wagon.Streams
|
||||
CLASS|org.apache.maven.wagon.TransferFailedException
|
||||
CLASS|org.apache.maven.wagon.UnsupportedProtocolException
|
||||
CLASS|org.apache.maven.wagon.Wagon$1
|
||||
CLASS|org.apache.maven.wagon.Wagon
|
||||
CLASS|org.apache.maven.wagon.WagonConstants
|
||||
CLASS|org.apache.maven.wagon.WagonException
|
||||
CLASS|org.apache.maven.wagon.WagonUtils
|
||||
CLASS|org.apache.maven.wagon.authentication.AuthenticationException
|
||||
CLASS|org.apache.maven.wagon.authentication.AuthenticationInfo
|
||||
CLASS|org.apache.maven.wagon.authorization.AuthorizationException
|
||||
CLASS|org.apache.maven.wagon.events.SessionEvent
|
||||
CLASS|org.apache.maven.wagon.events.SessionEventSupport
|
||||
CLASS|org.apache.maven.wagon.events.SessionListener
|
||||
CLASS|org.apache.maven.wagon.events.TransferEvent
|
||||
CLASS|org.apache.maven.wagon.events.TransferEventSupport
|
||||
CLASS|org.apache.maven.wagon.events.TransferListener
|
||||
CLASS|org.apache.maven.wagon.events.WagonEvent
|
||||
CLASS|org.apache.maven.wagon.observers.AbstractTransferListener
|
||||
CLASS|org.apache.maven.wagon.observers.ChecksumObserver
|
||||
CLASS|org.apache.maven.wagon.observers.Debug
|
||||
CLASS|org.apache.maven.wagon.proxy.ProxyInfo
|
||||
CLASS|org.apache.maven.wagon.repository.Repository
|
||||
CLASS|org.apache.maven.wagon.repository.RepositoryPermissions
|
||||
CLASS|org.apache.maven.wagon.resource.Resource
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.<init>()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getRepository()Lorg/apache/maven/wagon/repository/Repository;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.setRepository(Lorg/apache/maven/wagon/repository/Repository;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getProxyInfo()Lorg/apache/maven/wagon/proxy/ProxyInfo;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.setProxyInfo(Lorg/apache/maven/wagon/proxy/ProxyInfo;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getAuthenticationInfo()Lorg/apache/maven/wagon/authentication/AuthenticationInfo;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.setAuthenticationInfo(Lorg/apache/maven/wagon/authentication/AuthenticationInfo;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.isConnected()Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.openConnection()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.connect()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.connect(Lorg/apache/maven/wagon/repository/Repository;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.connect(Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/proxy/ProxyInfo;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.connect(Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/authentication/AuthenticationInfo;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.connect(Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/authentication/AuthenticationInfo;Lorg/apache/maven/wagon/proxy/ProxyInfo;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.disconnect()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.closeConnection()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.createParentDirectories(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getTransfer(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;Ljava/io/InputStream;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getTransfer(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;Ljava/io/InputStream;ZI)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.putTransfer(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;Ljava/io/OutputStream;Z)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.transfer(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;Ljava/io/OutputStream;Z)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.transfer(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/InputStream;Ljava/io/OutputStream;I)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.transfer(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/InputStream;Ljava/io/OutputStream;II)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireTransferProgress(Lorg/apache/maven/wagon/events/TransferEvent;[BI)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireGetCompleted(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireGetStarted(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireGetInitiated(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.firePutInitiated(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.firePutCompleted(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.firePutStarted(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionDisconnected()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionDisconnecting()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionLoggedIn()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionLoggedOff()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionOpened()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionOpening()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionConnectionRefused()V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionError(Ljava/lang/Exception;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireTransferDebug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireSessionDebug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.hasTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.addTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.removeTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.addSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.hasSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.removeSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.fireTransferError(Lorg/apache/maven/wagon/resource/Resource;Ljava/lang/Exception;I)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getSessionEventSupport()Lorg/apache/maven/wagon/events/SessionEventSupport;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.setSessionEventSupport(Lorg/apache/maven/wagon/events/SessionEventSupport;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getTransferEventSupport()Lorg/apache/maven/wagon/events/TransferEventSupport;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.setTransferEventSupport(Lorg/apache/maven/wagon/events/TransferEventSupport;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.postProcessListeners(Lorg/apache/maven/wagon/resource/Resource;Ljava/io/File;I)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.putDirectory(Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.supportsDirectoryCopy()Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.createZip(Ljava/util/List;Ljava/io/File;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.writeZipEntry(Ljava/util/zip/ZipOutputStream;Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getPath(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.isInteractive()Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.setInteractive(Z)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getFileList(Ljava/lang/String;)Ljava/util/List;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.resourceExists(Ljava/lang/String;)Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getProtocol()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.put(Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.getIfNewer(Ljava/lang/String;Ljava/io/File;J)Z
|
||||
METHOD|org.apache.maven.wagon.AbstractWagon.get(Ljava/lang/String;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.CommandExecutionException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.CommandExecutionException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.CommandExecutor$1.class$(Ljava/lang/String;)Ljava/lang/Class;
|
||||
METHOD|org.apache.maven.wagon.CommandExecutor.executeCommand(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.CommandExecutor.executeCommand(Ljava/lang/String;Z)Lorg/apache/maven/wagon/Streams;
|
||||
METHOD|org.apache.maven.wagon.CommandExecutor.<clinit>()V
|
||||
METHOD|org.apache.maven.wagon.ConnectionException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.ConnectionException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.InputData.<init>()V
|
||||
METHOD|org.apache.maven.wagon.InputData.getInputStream()Ljava/io/InputStream;
|
||||
METHOD|org.apache.maven.wagon.InputData.setInputStream(Ljava/io/InputStream;)V
|
||||
METHOD|org.apache.maven.wagon.InputData.getResource()Lorg/apache/maven/wagon/resource/Resource;
|
||||
METHOD|org.apache.maven.wagon.InputData.setResource(Lorg/apache/maven/wagon/resource/Resource;)V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.<init>(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.close()V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.equals(Ljava/lang/Object;)Z
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.flush()V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.getChannel()Ljava/nio/channels/FileChannel;
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.getFD()Ljava/io/FileDescriptor;
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.hashCode()I
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.toString()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.write([B)V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.write([BII)V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.write(I)V
|
||||
METHOD|org.apache.maven.wagon.LazyFileOutputStream.initialize()V
|
||||
METHOD|org.apache.maven.wagon.OutputData.<init>()V
|
||||
METHOD|org.apache.maven.wagon.OutputData.getOutputStream()Ljava/io/OutputStream;
|
||||
METHOD|org.apache.maven.wagon.OutputData.setOutputStream(Ljava/io/OutputStream;)V
|
||||
METHOD|org.apache.maven.wagon.OutputData.getResource()Lorg/apache/maven/wagon/resource/Resource;
|
||||
METHOD|org.apache.maven.wagon.OutputData.setResource(Lorg/apache/maven/wagon/resource/Resource;)V
|
||||
METHOD|org.apache.maven.wagon.PathUtils.<init>()V
|
||||
METHOD|org.apache.maven.wagon.PathUtils.dirname(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.filename(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.dirnames(Ljava/lang/String;)[Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.split(Ljava/lang/String;Ljava/lang/String;I)[Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.host(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.authorization(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.protocol(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.port(Ljava/lang/String;)I
|
||||
METHOD|org.apache.maven.wagon.PathUtils.basedir(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.user(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.password(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PathUtils.toRelative(Ljava/io/File;Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.PermissionModeUtils.<init>()V
|
||||
METHOD|org.apache.maven.wagon.PermissionModeUtils.getUserMaskFor(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.ResourceDoesNotExistException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.ResourceDoesNotExistException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.<init>()V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.fillInputData(Lorg/apache/maven/wagon/InputData;)V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.fillOutputData(Lorg/apache/maven/wagon/OutputData;)V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.openConnection()V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.closeConnection()V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.get(Ljava/lang/String;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.getIfNewer(Ljava/lang/String;Ljava/io/File;J)Z
|
||||
METHOD|org.apache.maven.wagon.StreamWagon.put(Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.Streams.<init>()V
|
||||
METHOD|org.apache.maven.wagon.Streams.getOut()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.Streams.setOut(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.Streams.getErr()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.Streams.setErr(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.TransferFailedException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.TransferFailedException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.UnsupportedProtocolException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.UnsupportedProtocolException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon$1.class$(Ljava/lang/String;)Ljava/lang/Class;
|
||||
METHOD|org.apache.maven.wagon.Wagon.get(Ljava/lang/String;Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.getIfNewer(Ljava/lang/String;Ljava/io/File;J)Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.put(Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.putDirectory(Ljava/io/File;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.resourceExists(Ljava/lang/String;)Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.getFileList(Ljava/lang/String;)Ljava/util/List;
|
||||
METHOD|org.apache.maven.wagon.Wagon.getProtocol()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.Wagon.supportsDirectoryCopy()Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.isInteractive()Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.setInteractive(Z)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.getRepository()Lorg/apache/maven/wagon/repository/Repository;
|
||||
METHOD|org.apache.maven.wagon.Wagon.setRepository(Lorg/apache/maven/wagon/repository/Repository;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.getAuthenticationInfo()Lorg/apache/maven/wagon/authentication/AuthenticationInfo;
|
||||
METHOD|org.apache.maven.wagon.Wagon.setAuthenticationInfo(Lorg/apache/maven/wagon/authentication/AuthenticationInfo;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.getProxyInfo()Lorg/apache/maven/wagon/proxy/ProxyInfo;
|
||||
METHOD|org.apache.maven.wagon.Wagon.setProxyInfo(Lorg/apache/maven/wagon/proxy/ProxyInfo;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.connect()V
|
||||
METHOD|org.apache.maven.wagon.Wagon.isConnected()Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.connect(Lorg/apache/maven/wagon/repository/Repository;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.connect(Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/proxy/ProxyInfo;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.connect(Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/authentication/AuthenticationInfo;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.connect(Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/authentication/AuthenticationInfo;Lorg/apache/maven/wagon/proxy/ProxyInfo;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.disconnect()V
|
||||
METHOD|org.apache.maven.wagon.Wagon.addSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.removeSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.hasSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.addTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.removeTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)V
|
||||
METHOD|org.apache.maven.wagon.Wagon.hasTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)Z
|
||||
METHOD|org.apache.maven.wagon.Wagon.<clinit>()V
|
||||
METHOD|org.apache.maven.wagon.WagonConstants.<init>()V
|
||||
METHOD|org.apache.maven.wagon.WagonException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.WagonException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.WagonException.getCause()Ljava/lang/Throwable;
|
||||
METHOD|org.apache.maven.wagon.WagonException.initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;
|
||||
METHOD|org.apache.maven.wagon.WagonUtils.<init>()V
|
||||
METHOD|org.apache.maven.wagon.WagonUtils.toString(Ljava/lang/String;Lorg/apache/maven/wagon/Wagon;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.WagonUtils.putDirectory(Ljava/io/File;Lorg/apache/maven/wagon/Wagon;Z)V
|
||||
METHOD|org.apache.maven.wagon.WagonUtils.getAuthInfo()Lorg/apache/maven/wagon/authentication/AuthenticationInfo;
|
||||
METHOD|org.apache.maven.wagon.WagonUtils.getUserGroup()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.WagonUtils.getUserName()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.<init>()V
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.getPassphrase()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.setPassphrase(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.getPrivateKey()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.setPrivateKey(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.getPassword()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.setPassword(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.getUserName()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.authentication.AuthenticationInfo.setUserName(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.authorization.AuthorizationException.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.authorization.AuthorizationException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.<init>(Lorg/apache/maven/wagon/Wagon;Lorg/apache/maven/wagon/repository/Repository;I)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.<init>(Lorg/apache/maven/wagon/Wagon;Lorg/apache/maven/wagon/repository/Repository;Ljava/lang/Exception;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.getEventType()I
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.getException()Ljava/lang/Exception;
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.setEventType(I)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.setException(Ljava/lang/Exception;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEvent.toString()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.<init>()V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.addSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.removeSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.hasSessionListener(Lorg/apache/maven/wagon/events/SessionListener;)Z
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionDisconnected(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionDisconnecting(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionLoggedIn(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionLoggedOff(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionOpened(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionOpening(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionConnectionRefused(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireDebug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionEventSupport.fireSessionError(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionOpening(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionOpened(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionDisconnecting(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionDisconnected(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionConnectionRefused(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionLoggedIn(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionLoggedOff(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.sessionError(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.SessionListener.debug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.<init>(Lorg/apache/maven/wagon/Wagon;Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/resource/Resource;Ljava/lang/Exception;I)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.<init>(Lorg/apache/maven/wagon/Wagon;Lorg/apache/maven/wagon/repository/Repository;Lorg/apache/maven/wagon/resource/Resource;II)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.getResource()Lorg/apache/maven/wagon/resource/Resource;
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.getException()Ljava/lang/Exception;
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.getRequestType()I
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.setRequestType(I)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.getEventType()I
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.setEventType(I)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.setResource(Lorg/apache/maven/wagon/resource/Resource;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.getLocalFile()Ljava/io/File;
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.setLocalFile(Ljava/io/File;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEvent.toString()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.<init>()V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.addTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.removeTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.hasTransferListener(Lorg/apache/maven/wagon/events/TransferListener;)Z
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.fireTransferStarted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.fireTransferProgress(Lorg/apache/maven/wagon/events/TransferEvent;[BI)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.fireTransferCompleted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.fireTransferError(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.fireDebug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferEventSupport.fireTransferInitiated(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferListener.transferInitiated(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferListener.transferStarted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferListener.transferProgress(Lorg/apache/maven/wagon/events/TransferEvent;[BI)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferListener.transferCompleted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferListener.transferError(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.events.TransferListener.debug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.events.WagonEvent.<init>(Lorg/apache/maven/wagon/Wagon;Lorg/apache/maven/wagon/repository/Repository;)V
|
||||
METHOD|org.apache.maven.wagon.events.WagonEvent.getWagon()Lorg/apache/maven/wagon/Wagon;
|
||||
METHOD|org.apache.maven.wagon.events.WagonEvent.getTimestamp()J
|
||||
METHOD|org.apache.maven.wagon.events.WagonEvent.setTimestamp(J)V
|
||||
METHOD|org.apache.maven.wagon.events.WagonEvent.getRepository()Lorg/apache/maven/wagon/repository/Repository;
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.<init>()V
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.transferInitiated(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.transferStarted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.transferProgress(Lorg/apache/maven/wagon/events/TransferEvent;[BI)V
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.transferCompleted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.transferError(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.AbstractTransferListener.debug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.<init>()V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.transferInitiated(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.transferStarted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.transferProgress(Lorg/apache/maven/wagon/events/TransferEvent;[BI)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.transferCompleted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.transferError(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.debug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.getActualChecksum()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.observers.ChecksumObserver.encode([B)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.<init>()V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.<init>(Ljava/io/PrintStream;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionOpening(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionOpened(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionDisconnecting(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionDisconnected(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionConnectionRefused(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionLoggedIn(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionLoggedOff(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.debug(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.transferInitiated(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.transferStarted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.transferProgress(Lorg/apache/maven/wagon/events/TransferEvent;[BI)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.transferCompleted(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.transferError(Lorg/apache/maven/wagon/events/TransferEvent;)V
|
||||
METHOD|org.apache.maven.wagon.observers.Debug.sessionError(Lorg/apache/maven/wagon/events/SessionEvent;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.<init>()V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getHost()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setHost(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getPassword()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setPassword(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getPort()I
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setPort(I)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getUserName()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setUserName(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getType()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setType(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getNonProxyHosts()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setNonProxyHosts(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getNtlmHost()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setNtlmHost(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.setNtlmDomain(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.proxy.ProxyInfo.getNtlmDomain()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.<init>()V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.<init>(Ljava/lang/String;Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getId()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setId(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getBasedir()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setBasedir(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setName(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getPort()I
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setPort(I)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setUrl(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getUrl()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getHost()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getName()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.toString()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getProtocol()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getPermissions()Lorg/apache/maven/wagon/repository/RepositoryPermissions;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setPermissions(Lorg/apache/maven/wagon/repository/RepositoryPermissions;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getParameter(Ljava/lang/String;)Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setParameters(Ljava/util/Properties;)V
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.equals(Ljava/lang/Object;)Z
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.hashCode()I
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getUsername()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.getPassword()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.Repository.setProtocol(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.<init>()V
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.getDirectoryMode()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.setDirectoryMode(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.getFileMode()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.setFileMode(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.getGroup()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.repository.RepositoryPermissions.setGroup(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.<init>()V
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.<init>(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.getName()Ljava/lang/String;
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.setName(Ljava/lang/String;)V
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.getLastModified()J
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.setLastModified(J)V
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.getContentLength()J
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.setContentLength(J)V
|
||||
METHOD|org.apache.maven.wagon.resource.Resource.toString()Ljava/lang/String;
|
||||
FILE|META-INF/
|
||||
FILE|META-INF/MANIFEST.MF
|
||||
FILE|META-INF/maven/
|
||||
FILE|META-INF/maven/org.apache.maven.wagon/
|
||||
FILE|META-INF/maven/org.apache.maven.wagon/wagon-provider-api/
|
||||
FILE|META-INF/maven/org.apache.maven.wagon/wagon-provider-api/pom.properties
|
||||
FILE|META-INF/maven/org.apache.maven.wagon/wagon-provider-api/pom.xml
|
||||
FILE|org/
|
||||
FILE|org/apache/
|
||||
FILE|org/apache/maven/
|
||||
FILE|org/apache/maven/wagon/
|
||||
FILE|org/apache/maven/wagon/AbstractWagon.class
|
||||
FILE|org/apache/maven/wagon/CommandExecutionException.class
|
||||
FILE|org/apache/maven/wagon/CommandExecutor$1.class
|
||||
FILE|org/apache/maven/wagon/CommandExecutor.class
|
||||
FILE|org/apache/maven/wagon/ConnectionException.class
|
||||
FILE|org/apache/maven/wagon/InputData.class
|
||||
FILE|org/apache/maven/wagon/LazyFileOutputStream.class
|
||||
FILE|org/apache/maven/wagon/OutputData.class
|
||||
FILE|org/apache/maven/wagon/PathUtils.class
|
||||
FILE|org/apache/maven/wagon/PermissionModeUtils.class
|
||||
FILE|org/apache/maven/wagon/ResourceDoesNotExistException.class
|
||||
FILE|org/apache/maven/wagon/StreamWagon.class
|
||||
FILE|org/apache/maven/wagon/Streams.class
|
||||
FILE|org/apache/maven/wagon/TransferFailedException.class
|
||||
FILE|org/apache/maven/wagon/UnsupportedProtocolException.class
|
||||
FILE|org/apache/maven/wagon/Wagon$1.class
|
||||
FILE|org/apache/maven/wagon/Wagon.class
|
||||
FILE|org/apache/maven/wagon/WagonConstants.class
|
||||
FILE|org/apache/maven/wagon/WagonException.class
|
||||
FILE|org/apache/maven/wagon/WagonUtils.class
|
||||
FILE|org/apache/maven/wagon/authentication/
|
||||
FILE|org/apache/maven/wagon/authentication/AuthenticationException.class
|
||||
FILE|org/apache/maven/wagon/authentication/AuthenticationInfo.class
|
||||
FILE|org/apache/maven/wagon/authorization/
|
||||
FILE|org/apache/maven/wagon/authorization/AuthorizationException.class
|
||||
FILE|org/apache/maven/wagon/events/
|
||||
FILE|org/apache/maven/wagon/events/SessionEvent.class
|
||||
FILE|org/apache/maven/wagon/events/SessionEventSupport.class
|
||||
FILE|org/apache/maven/wagon/events/SessionListener.class
|
||||
FILE|org/apache/maven/wagon/events/TransferEvent.class
|
||||
FILE|org/apache/maven/wagon/events/TransferEventSupport.class
|
||||
FILE|org/apache/maven/wagon/events/TransferListener.class
|
||||
FILE|org/apache/maven/wagon/events/WagonEvent.class
|
||||
FILE|org/apache/maven/wagon/observers/
|
||||
FILE|org/apache/maven/wagon/observers/AbstractTransferListener.class
|
||||
FILE|org/apache/maven/wagon/observers/ChecksumObserver.class
|
||||
FILE|org/apache/maven/wagon/observers/Debug.class
|
||||
FILE|org/apache/maven/wagon/proxy/
|
||||
FILE|org/apache/maven/wagon/proxy/ProxyInfo.class
|
||||
FILE|org/apache/maven/wagon/repository/
|
||||
FILE|org/apache/maven/wagon/repository/Repository.class
|
||||
FILE|org/apache/maven/wagon/repository/RepositoryPermissions.class
|
||||
FILE|org/apache/maven/wagon/resource/
|
||||
FILE|org/apache/maven/wagon/resource/Resource.class
|
|
@ -0,0 +1,188 @@
|
|||
package org.apache.maven.archiva.indexer;
|
||||
|
||||
/*
|
||||
* 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.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* AbstractIndexCreationTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractIndexCreationTestCase extends AbstractIndexerTestCase
|
||||
{
|
||||
protected abstract LuceneRepositoryContentRecord createSimpleRecord();
|
||||
|
||||
public void testIndexExists() throws Exception
|
||||
{
|
||||
assertFalse( "check index doesn't exist", index.exists() );
|
||||
|
||||
File indexLocation = index.getIndexDirectory();
|
||||
|
||||
// create empty directory
|
||||
indexLocation.mkdirs();
|
||||
assertFalse( "check index doesn't exist even if directory does", index.exists() );
|
||||
|
||||
// create index, with no records
|
||||
createEmptyIndex();
|
||||
assertTrue( "check index is considered to exist", index.exists() );
|
||||
|
||||
// Test non-directory
|
||||
FileUtils.deleteDirectory( indexLocation );
|
||||
indexLocation.createNewFile();
|
||||
try
|
||||
{
|
||||
index.exists();
|
||||
fail( "Index operation should fail as the location is not valid" );
|
||||
}
|
||||
catch ( RepositoryIndexException e )
|
||||
{
|
||||
// great
|
||||
}
|
||||
finally
|
||||
{
|
||||
indexLocation.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public void testAddRecordNoIndex() throws IOException, RepositoryIndexException, ParseException
|
||||
{
|
||||
LuceneRepositoryContentRecord record = createSimpleRecord();
|
||||
|
||||
index.indexRecords( Collections.singletonList( record ) );
|
||||
|
||||
IndexReader reader = IndexReader.open( index.getIndexDirectory() );
|
||||
try
|
||||
{
|
||||
Document document = reader.document( 0 );
|
||||
assertRecord( record, document );
|
||||
assertEquals( "Check index size", 1, reader.numDocs() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testAddRecordExistingEmptyIndex() throws IOException, RepositoryIndexException, ParseException
|
||||
{
|
||||
createEmptyIndex();
|
||||
|
||||
LuceneRepositoryContentRecord record = createSimpleRecord();
|
||||
|
||||
index.indexRecords( Collections.singletonList( record ) );
|
||||
|
||||
IndexReader reader = IndexReader.open( index.getIndexDirectory() );
|
||||
try
|
||||
{
|
||||
Document document = reader.document( 0 );
|
||||
assertRecord( record, document );
|
||||
assertEquals( "Check index size", 1, reader.numDocs() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testAddRecordInIndex() throws IOException, RepositoryIndexException, ParseException
|
||||
{
|
||||
createEmptyIndex();
|
||||
|
||||
LuceneRepositoryContentRecord record = createSimpleRecord();
|
||||
|
||||
index.indexRecords( Collections.singletonList( record ) );
|
||||
|
||||
// Do it again
|
||||
record = createSimpleRecord();
|
||||
|
||||
index.indexRecords( Collections.singletonList( record ) );
|
||||
|
||||
IndexReader reader = IndexReader.open( index.getIndexDirectory() );
|
||||
try
|
||||
{
|
||||
Document document = reader.document( 0 );
|
||||
assertRecord( record, document );
|
||||
assertEquals( "Check index size", 1, reader.numDocs() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteRecordInIndex() throws IOException, RepositoryIndexException
|
||||
{
|
||||
createEmptyIndex();
|
||||
|
||||
LuceneRepositoryContentRecord record = createSimpleRecord();
|
||||
|
||||
index.indexRecords( Collections.singletonList( record ) );
|
||||
|
||||
index.deleteRecords( Collections.singletonList( record ) );
|
||||
|
||||
IndexReader reader = IndexReader.open( index.getIndexDirectory() );
|
||||
try
|
||||
{
|
||||
assertEquals( "No documents", 0, reader.numDocs() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteRecordNotInIndex() throws IOException, RepositoryIndexException
|
||||
{
|
||||
createEmptyIndex();
|
||||
|
||||
LuceneRepositoryContentRecord record = createSimpleRecord();
|
||||
|
||||
index.deleteRecords( Collections.singletonList( record ) );
|
||||
|
||||
IndexReader reader = IndexReader.open( index.getIndexDirectory() );
|
||||
try
|
||||
{
|
||||
assertEquals( "No documents", 0, reader.numDocs() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteRecordNoIndex() throws IOException, RepositoryIndexException
|
||||
{
|
||||
LuceneRepositoryContentRecord record = createSimpleRecord();
|
||||
|
||||
index.deleteRecords( Collections.singleton( record ) );
|
||||
|
||||
assertFalse( index.exists() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
package org.apache.maven.archiva.indexer;
|
||||
|
||||
/*
|
||||
* 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 org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AbstractIndexerTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractIndexerTestCase extends PlexusTestCase
|
||||
{
|
||||
protected RepositoryContentIndex index;
|
||||
|
||||
protected LuceneIndexHandlers indexHandlers;
|
||||
|
||||
public abstract String getIndexName();
|
||||
|
||||
protected void assertRecord( LuceneRepositoryContentRecord expectedRecord, Document luceneDocument )
|
||||
throws ParseException
|
||||
{
|
||||
LuceneRepositoryContentRecord actualRecord = indexHandlers.getConverter().convert( luceneDocument );
|
||||
assertRecord( expectedRecord, actualRecord );
|
||||
}
|
||||
|
||||
protected void assertRecord( LuceneRepositoryContentRecord expectedRecord,
|
||||
LuceneRepositoryContentRecord actualRecord )
|
||||
{
|
||||
assertEquals( expectedRecord, actualRecord );
|
||||
}
|
||||
|
||||
public abstract RepositoryContentIndex createIndex( RepositoryContentIndexFactory indexFactory,
|
||||
ArchivaRepository repository );
|
||||
|
||||
public abstract LuceneIndexHandlers getIndexHandler();
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
RepositoryContentIndexFactory indexFactory =
|
||||
(RepositoryContentIndexFactory) lookup( RepositoryContentIndexFactory.class.getName(), "lucene" );
|
||||
|
||||
File repoDir = new File( getBasedir(), "src/test/managed-repository" );
|
||||
|
||||
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
|
||||
|
||||
String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" );
|
||||
|
||||
ArchivaRepository repository = new ArchivaRepository( "testDefaultRepo", "Test Default Repository", repoUri );
|
||||
|
||||
File indexLocation = new File( "target/index-" + getIndexName() + "-" + getName() + "/" );
|
||||
|
||||
MockConfiguration config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
|
||||
|
||||
RepositoryConfiguration repoConfig = new RepositoryConfiguration();
|
||||
repoConfig.setId( repository.getId() );
|
||||
repoConfig.setName( repository.getModel().getName() );
|
||||
repoConfig.setUrl( repository.getModel().getUrl() );
|
||||
repoConfig.setIndexDir( indexLocation.getAbsolutePath() );
|
||||
|
||||
if ( indexLocation.exists() )
|
||||
{
|
||||
FileUtils.deleteDirectory( indexLocation );
|
||||
}
|
||||
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
|
||||
index = createIndex( indexFactory, repository );
|
||||
|
||||
indexHandlers = getIndexHandler();
|
||||
}
|
||||
|
||||
protected Map getArchivaArtifactDumpMap()
|
||||
{
|
||||
Map dumps = new HashMap();
|
||||
|
||||
// archiva-common-1.0.jar.txt
|
||||
dumps.put( "archiva-common", createArchivaArtifact( "org.apache.maven.archiva", "archiva-common", "1.0", "",
|
||||
"jar" ) );
|
||||
|
||||
// continuum-webapp-1.0.3-SNAPSHOT.war.txt
|
||||
dumps.put( "continuum-webapp", createArchivaArtifact( "org.apache.maven.continuum", "continuum-webapp",
|
||||
"1.0.3-SNAPSHOT", "", "war" ) );
|
||||
|
||||
// daytrader-ear-1.1.ear.txt
|
||||
dumps.put( "daytrader-ear", createArchivaArtifact( "org.apache.geronimo", "daytrader-ear", "1.1", "", "ear" ) );
|
||||
|
||||
// maven-archetype-simple-1.0-alpha-4.jar.txt
|
||||
dumps.put( "maven-archetype-simple", createArchivaArtifact( "org.apache.maven", "maven-archetype-simple",
|
||||
"1.0-alpha-4", "", "maven-archetype" ) );
|
||||
|
||||
// maven-help-plugin-2.0.2-20070119.121239-2.jar.txt
|
||||
dumps.put( "maven-help-plugin", createArchivaArtifact( "org.apache.maven.plugins", "maven-help-plugin",
|
||||
"2.0.2-20070119.121239-2", "", "maven-plugin" ) );
|
||||
|
||||
// redback-authorization-open-1.0-alpha-1-SNAPSHOT.jar.txt
|
||||
dumps.put( "redback-authorization-open", createArchivaArtifact( "org.codehaus.plexus.redback",
|
||||
"redback-authorization-open",
|
||||
"1.0-alpha-1-SNAPSHOT", "", "jar" ) );
|
||||
|
||||
// testng-5.1-jdk15.jar.txt
|
||||
dumps.put( "testng", createArchivaArtifact( "org.testng", "testng", "5.1", "jdk15", "jar" ) );
|
||||
|
||||
// wagon-provider-api-1.0-beta-3-20070209.213958-2.jar.txt
|
||||
dumps.put( "wagon-provider-api", createArchivaArtifact( "org.apache.maven.wagon", "wagon-provider-api",
|
||||
"1.0-beta-3-20070209.213958-2", "", "jar" ) );
|
||||
|
||||
return dumps;
|
||||
}
|
||||
|
||||
protected File getDumpFile( ArchivaArtifact artifact )
|
||||
{
|
||||
File dumpDir = new File( getBasedir(), "src/test/artifact-dumps" );
|
||||
StringBuffer filename = new StringBuffer();
|
||||
|
||||
filename.append( artifact.getArtifactId() ).append( "-" ).append( artifact.getVersion() );
|
||||
|
||||
if ( artifact.hasClassifier() )
|
||||
{
|
||||
filename.append( "-" ).append( artifact.getClassifier() );
|
||||
}
|
||||
|
||||
filename.append( "." );
|
||||
|
||||
// TODO: use the ArtifactExtensionMapping object!
|
||||
if ( "maven-plugin".equals( artifact.getType() ) || "maven-archetype".equals( artifact.getType() ) )
|
||||
{
|
||||
filename.append( "jar" );
|
||||
}
|
||||
else
|
||||
{
|
||||
filename.append( artifact.getType() );
|
||||
}
|
||||
filename.append( ".txt" );
|
||||
|
||||
File dumpFile = new File( dumpDir, filename.toString() );
|
||||
|
||||
if ( !dumpFile.exists() )
|
||||
{
|
||||
fail( "Dump file " + dumpFile.getAbsolutePath() + " does not exist (should it?)." );
|
||||
}
|
||||
|
||||
return dumpFile;
|
||||
}
|
||||
|
||||
private ArchivaArtifact createArchivaArtifact( String groupId, String artifactId, String version,
|
||||
String classifier, String type )
|
||||
{
|
||||
ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type );
|
||||
return artifact;
|
||||
}
|
||||
|
||||
protected void createEmptyIndex() throws IOException
|
||||
{
|
||||
createIndex( Collections.EMPTY_LIST );
|
||||
}
|
||||
|
||||
protected void createIndex( List documents ) throws IOException
|
||||
{
|
||||
IndexWriter writer = new IndexWriter( index.getIndexDirectory(), indexHandlers.getAnalyzer(), true );
|
||||
for ( Iterator i = documents.iterator(); i.hasNext(); )
|
||||
{
|
||||
Document document = (Document) i.next();
|
||||
writer.addDocument( document );
|
||||
}
|
||||
writer.optimize();
|
||||
writer.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package org.apache.maven.archiva.indexer;
|
||||
|
||||
/*
|
||||
* 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.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.queryParser.QueryParser;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneQuery;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.ComparisonFailure;
|
||||
|
||||
/**
|
||||
* AbstractSearchTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractSearchTestCase extends AbstractIndexerTestCase
|
||||
{
|
||||
protected Map records;
|
||||
|
||||
protected abstract Map createSampleRecordsMap();
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
records = createSampleRecordsMap();
|
||||
|
||||
index.indexRecords( records.values() );
|
||||
}
|
||||
|
||||
protected Query createExactMatchQuery( String field, String value )
|
||||
{
|
||||
return new TermQuery( new Term( field, value ) );
|
||||
}
|
||||
|
||||
protected Query createMatchQuery( String field, String value ) throws ParseException
|
||||
{
|
||||
QueryParser queryParser = new QueryParser( field, indexHandlers.getAnalyzer() );
|
||||
queryParser.setLowercaseExpandedTerms( true );
|
||||
return queryParser.parse( value );
|
||||
}
|
||||
|
||||
protected void assertResults( String expectedKeys[], List actualResults )
|
||||
{
|
||||
if ( actualResults == null )
|
||||
{
|
||||
fail( "Got null results, expected <" + expectedKeys.length + "> results." );
|
||||
}
|
||||
|
||||
if ( actualResults.isEmpty() )
|
||||
{
|
||||
fail( "Got empty results, expected <" + expectedKeys.length + "> results." );
|
||||
}
|
||||
|
||||
if ( expectedKeys.length != actualResults.size() )
|
||||
{
|
||||
dumpResults( actualResults );
|
||||
throw new ComparisonFailure( "Results count", String.valueOf( expectedKeys.length ),
|
||||
String.valueOf( actualResults.size() ) );
|
||||
}
|
||||
|
||||
assertEquals( "Results count", expectedKeys.length, actualResults.size() );
|
||||
|
||||
for ( int i = 0; i < expectedKeys.length; i++ )
|
||||
{
|
||||
String key = expectedKeys[i];
|
||||
LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) records.get( key );
|
||||
|
||||
if ( record == null )
|
||||
{
|
||||
dumpResults( actualResults );
|
||||
fail( "Expected record <" + key
|
||||
+ "> not in records map (smack the unit test developer, tell them to fix method "
|
||||
+ getName() + ")" );
|
||||
}
|
||||
|
||||
if ( !actualResults.contains( record ) )
|
||||
{
|
||||
dumpResults( actualResults );
|
||||
fail( "Results should contain expected record: " + record );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void dumpResults( List results )
|
||||
{
|
||||
System.out.println( "Results <" + results.size() + "> - " + getName() );
|
||||
int i = 1;
|
||||
for ( Iterator iter = results.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Object result = (Object) iter.next();
|
||||
System.out.println( "Result [" + ( i++ ) + "] : " + result );
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertNoResults( List results )
|
||||
{
|
||||
if ( results == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !results.isEmpty() )
|
||||
{
|
||||
dumpResults( results );
|
||||
fail( "Expected no results, but actually got <" + results.size() + "> entries." );
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertQueryExactMatchNoResults( String key, String term ) throws RepositoryIndexSearchException
|
||||
{
|
||||
Query query = createExactMatchQuery( key, term );
|
||||
List results = index.search( new LuceneQuery( query ) );
|
||||
assertNoResults( results );
|
||||
}
|
||||
|
||||
protected void assertQueryExactMatch( String key, String names[], String term ) throws RepositoryIndexSearchException
|
||||
{
|
||||
Query query = createExactMatchQuery( key, term );
|
||||
List results = index.search( new LuceneQuery( query ) );
|
||||
assertResults( names, results );
|
||||
}
|
||||
|
||||
protected void assertQueryMatch( String key, String names[], String term ) throws Exception
|
||||
{
|
||||
Query query = createMatchQuery( key, term );
|
||||
List results = index.search( new LuceneQuery( query ) );
|
||||
assertResults( names, results );
|
||||
}
|
||||
|
||||
protected void assertQueryMatchNoResults( String key, String term ) throws Exception
|
||||
{
|
||||
Query query = createMatchQuery( key, term );
|
||||
List results = index.search( new LuceneQuery( query ) );
|
||||
assertNoResults( results );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.apache.maven.archiva.indexer;
|
||||
|
||||
/*
|
||||
* 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.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* AllTests - conveinence test suite for IDE users.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AllTests
|
||||
{
|
||||
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.indexer" );
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTest( org.apache.maven.archiva.indexer.bytecode.AllTests.suite() );
|
||||
suite.addTest( org.apache.maven.archiva.indexer.hashcodes.AllTests.suite() );
|
||||
suite.addTest( org.apache.maven.archiva.indexer.query.AllTests.suite() );
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.apache.maven.archiva.indexer;
|
||||
|
||||
/*
|
||||
* 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.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.codehaus.plexus.registry.RegistryException;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
|
||||
/**
|
||||
* MockConfiguration
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration"
|
||||
* role-hint="mock"
|
||||
*/
|
||||
public class MockConfiguration implements ArchivaConfiguration
|
||||
{
|
||||
private Configuration configuration = new Configuration();
|
||||
|
||||
public void addChangeListener( RegistryListener listener )
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public Configuration getConfiguration()
|
||||
{
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void save( Configuration configuration ) throws RegistryException
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.archiva;
|
||||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -33,10 +33,10 @@ public class AllTests
|
|||
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva" );
|
||||
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.indexer.bytecode" );
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTest( org.apache.maven.archiva.repository.AllTests.suite() );
|
||||
suite.addTest( org.apache.maven.archiva.layer.AllTests.suite() );
|
||||
suite.addTestSuite( BytecodeSearchTest.class );
|
||||
suite.addTestSuite( BytecodeIndexTest.class );
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.indexer.AbstractIndexCreationTestCase;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* BytecodeIndexTest
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeIndexTest extends AbstractIndexCreationTestCase
|
||||
{
|
||||
public String getIndexName()
|
||||
{
|
||||
return "bytecode";
|
||||
}
|
||||
|
||||
public LuceneIndexHandlers getIndexHandler()
|
||||
{
|
||||
return new BytecodeHandlers();
|
||||
}
|
||||
|
||||
public RepositoryContentIndex createIndex( RepositoryContentIndexFactory indexFactory, ArchivaRepository repository )
|
||||
{
|
||||
return indexFactory.createBytecodeIndex( repository );
|
||||
}
|
||||
|
||||
protected LuceneRepositoryContentRecord createSimpleRecord()
|
||||
{
|
||||
Map dumps = getArchivaArtifactDumpMap();
|
||||
ArchivaArtifact artifact = (ArchivaArtifact) dumps.get( "archiva-common" );
|
||||
|
||||
File dumpFile = getDumpFile( artifact );
|
||||
return BytecodeRecordLoader.loadRecord( dumpFile, artifact );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package org.apache.maven.archiva.indexer.bytecode;
|
||||
|
||||
/*
|
||||
* 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.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifactJavaDetails;
|
||||
import org.apache.maven.archiva.model.platform.JavaArtifactHelper;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
/**
|
||||
* BytecodeRecordLoader - Utility method for loading dump files into BytecordRecords.
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BytecodeRecordLoader
|
||||
{
|
||||
private static Map cache = new HashMap();
|
||||
|
||||
public static BytecodeRecord loadRecord( File dumpFile, ArchivaArtifact artifact )
|
||||
{
|
||||
BytecodeRecord record = (BytecodeRecord) cache.get( artifact );
|
||||
if ( record != null )
|
||||
{
|
||||
return record;
|
||||
}
|
||||
|
||||
record = new BytecodeRecord();
|
||||
record.setArtifact( artifact );
|
||||
|
||||
record.setClasses( new ArrayList() );
|
||||
record.setMethods( new ArrayList() );
|
||||
record.setFiles( new ArrayList() );
|
||||
|
||||
FileReader freader = null;
|
||||
BufferedReader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
freader = new FileReader( dumpFile );
|
||||
reader = new BufferedReader( freader );
|
||||
|
||||
String line = reader.readLine();
|
||||
while ( line != null )
|
||||
{
|
||||
if ( line.startsWith( "FILENAME|" ) )
|
||||
{
|
||||
String filename = line.substring( "FILENAME|".length() );
|
||||
record.setFilename( filename );
|
||||
}
|
||||
else if ( line.startsWith( "SIZE|" ) )
|
||||
{
|
||||
String size = line.substring( "SIZE|".length() );
|
||||
record.getArtifact().getModel().setSize( Long.parseLong( size ) );
|
||||
}
|
||||
else if ( line.startsWith( "HASH_MD5|" ) )
|
||||
{
|
||||
String md5 = line.substring( "HASH_MD5|".length() );
|
||||
record.getArtifact().getModel().setChecksumMD5( md5 );
|
||||
}
|
||||
else if ( line.startsWith( "HASH_SHA1|" ) )
|
||||
{
|
||||
String sha1 = line.substring( "HASH_SHA1|".length() );
|
||||
record.getArtifact().getModel().setChecksumSHA1( sha1 );
|
||||
}
|
||||
else if ( line.startsWith( "HASH_BYTECODE|" ) )
|
||||
{
|
||||
String hash = line.substring( "HASH_BYTECODE|".length() );
|
||||
ArchivaArtifactJavaDetails javaDetails = JavaArtifactHelper.getJavaDetails( record.getArtifact() );
|
||||
javaDetails.setChecksumBytecode( hash );
|
||||
}
|
||||
else if ( line.startsWith( "JDK|" ) )
|
||||
{
|
||||
String jdk = line.substring( "JDK|".length() );
|
||||
ArchivaArtifactJavaDetails javaDetails = JavaArtifactHelper.getJavaDetails( record.getArtifact() );
|
||||
javaDetails.setJdk( jdk );
|
||||
}
|
||||
else if ( line.startsWith( "CLASS|" ) )
|
||||
{
|
||||
String classname = line.substring( "CLASS|".length() );
|
||||
record.getClasses().add( classname );
|
||||
}
|
||||
else if ( line.startsWith( "METHOD|" ) )
|
||||
{
|
||||
String methodName = line.substring( "METHOD|".length() );
|
||||
record.getMethods().add( methodName );
|
||||
}
|
||||
else if ( line.startsWith( "FILE|" ) )
|
||||
{
|
||||
String fileentry = line.substring( "FILE|".length() );
|
||||
record.getFiles().add( fileentry );
|
||||
}
|
||||
|
||||
line = reader.readLine();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new AssertionFailedError( "Unable to load record " + dumpFile + " from disk: " + e.getMessage() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( reader );
|
||||
IOUtil.close( freader );
|
||||
}
|
||||
|
||||
cache.put( artifact, record );
|
||||
|
||||
return record;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue