summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java13
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactInfo.jspf2
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java1
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java54
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java31
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java4
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java73
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java112
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java6
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java2
-rw-r--r--archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java192
-rw-r--r--archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java1
-rw-r--r--archiva-modules/plugins/problem-reports/pom.xml1
-rw-r--r--archiva-modules/plugins/problem-reports/src/test/resources/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest-context.xml (renamed from archiva-modules/plugins/problem-reports/src/test/resources/META-INF/spring-context.xml)0
-rw-r--r--archiva-modules/pom.xml28
16 files changed, 366 insertions, 160 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java
index fec93b15e..82d9adaa8 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java
@@ -19,12 +19,6 @@ package org.apache.archiva.consumers.metadata;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.archiva.metadata.model.ArtifactMetadata;
@@ -51,6 +45,12 @@ import org.codehaus.plexus.registry.RegistryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* Take an artifact off of disk and put it into the metadata repository.
*
@@ -185,6 +185,7 @@ public class ArchivaMetadataCreationConsumer
createVersionMetadata = true;
}
+ // TODO: merge with storage implementation, add Maven facet
ArtifactMetadata artifactMeta = new ArtifactMetadata();
artifactMeta.setRepositoryId( repository.getId() );
artifactMeta.setNamespace( artifact.getGroupId() );
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
index 2c4fdc513..69c5b7cb9 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
@@ -19,7 +19,7 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %>
+<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %>
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
<html>
@@ -98,7 +98,7 @@
<c:if test="${not empty projectVersions}">
<%-- show shared project information (MRM-1041) TODO - share JSP code with artifactInfo.jspf --%>
- <c:set var="mavenFacet" value="${sharedModel.facets['org.apache.archiva.metadata.repository.storage.maven2']}" />
+ <c:set var="mavenFacet" value="${sharedModel.facets['org.apache.archiva.metadata.repository.storage.maven2.project']}" />
<h2>Versions</h2>
<div id="nameColumn" class="versions">
<a class="expand" href="#">Artifact Info</a>
@@ -188,4 +188,4 @@
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactInfo.jspf b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactInfo.jspf
index c256bf643..edfc8c850 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactInfo.jspf
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactInfo.jspf
@@ -43,7 +43,7 @@
<blockquote>${model.description}</blockquote>
</c:if>
-<c:set var="mavenFacet" value="${model.facets['org.apache.archiva.metadata.repository.storage.maven2']}" />
+<c:set var="mavenFacet" value="${model.facets['org.apache.archiva.metadata.repository.storage.maven2.project']}" />
<table class="infoTable">
<tr>
<th>Repository</th>
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java
index aee6c4b6b..b5b7307cd 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ArtifactMetadata.java
@@ -22,6 +22,7 @@ package org.apache.archiva.metadata.model;
import java.util.Date;
public class ArtifactMetadata
+ extends FacetedMetadata
{
private String id;
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java
new file mode 100644
index 000000000..a3df5e339
--- /dev/null
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java
@@ -0,0 +1,54 @@
+package org.apache.archiva.metadata.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class FacetedMetadata
+{
+ private Map<String, MetadataFacet> facets = new HashMap<String, MetadataFacet>();
+
+ public void addFacet( MetadataFacet metadataFacet )
+ {
+ this.facets.put( metadataFacet.getFacetId(), metadataFacet );
+ }
+
+ public MetadataFacet getFacet( String facetId )
+ {
+ return this.facets.get( facetId );
+ }
+
+ public Map<String, MetadataFacet> getFacets()
+ {
+ return facets;
+ }
+
+ public Collection<MetadataFacet> getFacetList()
+ {
+ return this.facets.values();
+ }
+
+ public Collection<String> getFacetIds()
+ {
+ return this.facets.keySet();
+ }
+}
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java
index 9973c45c4..b61135e78 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java
@@ -20,12 +20,10 @@ package org.apache.archiva.metadata.model;
*/
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
public class ProjectVersionMetadata
+ extends FacetedMetadata
{
private String id;
@@ -45,8 +43,6 @@ public class ProjectVersionMetadata
private List<License> licenses = new ArrayList<License>();
- private Map<String, MetadataFacet> facets = new HashMap<String, MetadataFacet>();
-
private List<MailingList> mailingLists = new ArrayList<MailingList>();
private List<Dependency> dependencies = new ArrayList<Dependency>();
@@ -153,31 +149,6 @@ public class ProjectVersionMetadata
this.licenses.add( license );
}
- public void addFacet( MetadataFacet metadataFacet )
- {
- this.facets.put( metadataFacet.getFacetId(), metadataFacet );
- }
-
- public MetadataFacet getFacet( String facetId )
- {
- return this.facets.get( facetId );
- }
-
- public Map<String, MetadataFacet> getFacets()
- {
- return facets;
- }
-
- public Collection<MetadataFacet> getFacetList()
- {
- return this.facets.values();
- }
-
- public Collection<String> getFacetIds()
- {
- return this.facets.keySet();
- }
-
public void setMailingLists( List<MailingList> mailingLists )
{
this.mailingLists = mailingLists;
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
index 39dc81441..d712980f0 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
@@ -149,6 +149,7 @@ public class Maven2RepositoryMetadataResolver
}
}
+ // TODO: won't work well with some other layouts, might need to convert artifact parts to ID by path translator
String id = projectId + "-" + artifactVersion + ".pom";
File file = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, id );
@@ -499,7 +500,8 @@ public class Maven2RepositoryMetadataResolver
private ArtifactMetadata getArtifactFromFile( String repoId, String namespace, String projectId,
String projectVersion, File file )
{
- ArtifactMetadata metadata = pathTranslator.getArtifactFromId( repoId, namespace, projectId, projectVersion, file.getName() );
+ ArtifactMetadata metadata = pathTranslator.getArtifactFromId( repoId, namespace, projectId, projectVersion,
+ file.getName() );
metadata.setWhenGathered( new Date() );
metadata.setFileLastModified( file.lastModified() );
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java
index acec739cf..e67a8e121 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java
@@ -39,6 +39,8 @@ public class Maven2RepositoryPathTranslator
private static final char GROUP_SEPARATOR = '.';
+ private static final Pattern TIMESTAMP_PATTERN = Pattern.compile( "([0-9]{8}.[0-9]{6})-([0-9]+).*" );
+
public File toFile( File basedir, String namespace, String projectId, String projectVersion, String filename )
{
return new File( basedir, toPath( namespace, projectId, projectVersion, filename ) );
@@ -133,28 +135,6 @@ public class Maven2RepositoryPathTranslator
return mainVersion + m.group( 1 );
}
- public ArtifactMetadata getArtifactFromId( String repoId, String namespace, String projectId, String projectVersion,
- String id )
- {
- ArtifactMetadata metadata = new ArtifactMetadata();
- metadata.setId( id );
- metadata.setProject( projectId );
- metadata.setNamespace( namespace );
- metadata.setRepositoryId( repoId );
-
- if ( VersionUtil.isGenericSnapshot( projectVersion ) )
- {
- String version = parseTimestampedVersionFromId( projectId, projectVersion, id );
-
- metadata.setVersion( version );
- }
- else
- {
- metadata.setVersion( projectVersion );
- }
- return metadata;
- }
-
public ArtifactMetadata getArtifactForPath( String repoId, String relativePath )
{
String[] parts = relativePath.replace( '\\', '/' ).split( "/" );
@@ -171,31 +151,51 @@ public class Maven2RepositoryPathTranslator
String artifactId = parts[--len];
String groupId = StringUtils.join( Arrays.copyOfRange( parts, 0, len ), '.' );
- if ( !id.startsWith( artifactId + "-" ) )
+ return getArtifactFromId( repoId, groupId, artifactId, baseVersion, id );
+ }
+
+ public ArtifactMetadata getArtifactFromId( String repoId, String namespace, String projectId, String projectVersion,
+ String id )
+ {
+ if ( !id.startsWith( projectId + "-" ) )
{
throw new IllegalArgumentException( "Not a valid artifact path in a Maven 2 repository, filename '" + id +
- "' doesn't start with artifact ID '" + artifactId + "'" );
+ "' doesn't start with artifact ID '" + projectId + "'" );
}
- int index = artifactId.length() + 1;
+ MavenArtifactFacet facet = new MavenArtifactFacet();
+
+ int index = projectId.length() + 1;
String version;
- if ( id.substring( index ).startsWith( baseVersion ) && !VersionUtil.isUniqueSnapshot( baseVersion ) )
+ String idSubStrFromVersion = id.substring( index );
+ if ( idSubStrFromVersion.startsWith( projectVersion ) && !VersionUtil.isUniqueSnapshot( projectVersion ) )
{
// non-snapshot versions, or non-timestamped snapshot versions
- version = baseVersion;
+ version = projectVersion;
}
- else if ( VersionUtil.isGenericSnapshot( baseVersion ) )
+ else if ( VersionUtil.isGenericSnapshot( projectVersion ) )
{
// timestamped snapshots
try
{
- version = parseTimestampedVersionFromId( artifactId, baseVersion, id );
+ int mainVersionLength = projectVersion.length() - 8; // 8 is length of "SNAPSHOT"
+ if ( mainVersionLength == 0 )
+ {
+ throw new IllegalArgumentException(
+ "Timestamped snapshots must contain the main version, filename was '" + id + "'" );
+ }
+
+ Matcher m = TIMESTAMP_PATTERN.matcher( idSubStrFromVersion.substring( mainVersionLength ) );
+ m.matches();
+ String timestamp = m.group( 1 );
+ String buildNumber = m.group( 2 );
+ version = idSubStrFromVersion.substring( 0, mainVersionLength ) + timestamp + "-" + buildNumber;
}
catch ( IllegalStateException e )
{
throw new IllegalArgumentException(
"Not a valid artifact path in a Maven 2 repository, filename '" + id +
- "' doesn't contain a timestamped version matching snapshot '" + baseVersion + "'" );
+ "' doesn't contain a timestamped version matching snapshot '" + projectVersion + "'" );
}
}
else
@@ -203,7 +203,7 @@ public class Maven2RepositoryPathTranslator
// invalid
throw new IllegalArgumentException(
"Not a valid artifact path in a Maven 2 repository, filename '" + id + "' doesn't contain version '" +
- baseVersion + "'" );
+ projectVersion + "'" );
}
String classifier;
@@ -249,11 +249,16 @@ public class Maven2RepositoryPathTranslator
ArtifactMetadata metadata = new ArtifactMetadata();
metadata.setId( id );
- metadata.setNamespace( groupId );
- metadata.setProject( artifactId );
+ metadata.setNamespace( namespace );
+ metadata.setProject( projectId );
metadata.setRepositoryId( repoId );
metadata.setVersion( version );
- // TODO: set classifier and extension on Maven facet
+
+ facet.setClassifier( classifier );
+ // TODO: migrate here from ArtifactExtensionMapping and make extensible
+// facet.setType( );
+ metadata.addFacet( facet );
+
return metadata;
}
}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java
new file mode 100644
index 000000000..f24ca0cc0
--- /dev/null
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java
@@ -0,0 +1,112 @@
+package org.apache.archiva.metadata.repository.storage.maven2;
+
+/*
+ * 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.archiva.metadata.model.MetadataFacet;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MavenArtifactFacet
+ implements MetadataFacet
+{
+ private String classifier;
+
+ private String type;
+
+ private String timestamp;
+
+ private int buildNumber;
+
+ public static final String FACET_ID = "org.apache.archiva.metadata.repository.storage.maven2.artifact";
+
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ public void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ public String getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setTimestamp( String timestamp )
+ {
+ this.timestamp = timestamp;
+ }
+
+ public int getBuildNumber()
+ {
+ return buildNumber;
+ }
+
+ public void setBuildNumber( int buildNumber )
+ {
+ this.buildNumber = buildNumber;
+ }
+
+ public String getFacetId()
+ {
+ return FACET_ID;
+ }
+
+ public String getName()
+ {
+ // TODO: not needed, perhaps artifact/version metadata facet should be separate interface?
+ return null;
+ }
+
+ public Map<String, String> toProperties()
+ {
+ HashMap<String, String> properties = new HashMap<String, String>();
+ properties.put( FACET_ID + ":type", type );
+ properties.put( FACET_ID + ":classifier", classifier );
+ properties.put( FACET_ID + ":timestamp", timestamp );
+ properties.put( FACET_ID + ":buildNumber", Integer.toString( buildNumber ));
+ return properties;
+ }
+
+ public void fromProperties( Map<String, String> properties )
+ {
+ type = properties.get( FACET_ID + ":type" );
+ classifier = properties.get( FACET_ID + ":classifier" );
+ timestamp = properties.get( FACET_ID + ":timestamp" );
+ String buildNumber = properties.get( FACET_ID + ":buildNumber" );
+ if ( buildNumber != null )
+ {
+ this.buildNumber = Integer.valueOf( buildNumber );
+ }
+ }
+}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java
index 0145b9482..93df5a1e1 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java
@@ -19,11 +19,11 @@ package org.apache.archiva.metadata.repository.storage.maven2;
* under the License.
*/
+import org.apache.archiva.metadata.model.MetadataFacet;
+
import java.util.HashMap;
import java.util.Map;
-import org.apache.archiva.metadata.model.MetadataFacet;
-
public class MavenProjectFacet
implements MetadataFacet
{
@@ -35,7 +35,7 @@ public class MavenProjectFacet
private String packaging;
- public static final String FACET_ID = "org.apache.archiva.metadata.repository.storage.maven2";
+ public static final String FACET_ID = "org.apache.archiva.metadata.repository.storage.maven2.project";
public String getGroupId()
{
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java
index e874b3f40..81a99b910 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacetFactory.java
@@ -23,7 +23,7 @@ import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.model.MetadataFacetFactory;
/**
- * @plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.metadata.repository.storage.maven2"
+ * @plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.metadata.repository.storage.maven2.project"
*/
public class MavenProjectFacetFactory
implements MetadataFacetFactory
diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
index 72d82ef71..6ee649540 100644
--- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
+++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
@@ -19,14 +19,9 @@ package org.apache.archiva.metadata.repository.storage.maven2;
* under the License.
*/
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.Dependency;
+import org.apache.archiva.metadata.model.FacetedMetadata;
import org.apache.archiva.metadata.model.License;
import org.apache.archiva.metadata.model.MailingList;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
@@ -40,6 +35,13 @@ import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
public class Maven2RepositoryMetadataResolverTest
extends PlexusInSpringTestCase
{
@@ -80,8 +82,8 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetProjectVersionMetadata()
throws Exception
{
- ProjectVersionMetadata metadata =
- resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1" );
+ ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva",
+ "archiva-common", "1.2.1" );
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
assertEquals( "jar", facet.getPackaging() );
assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() );
@@ -131,6 +133,44 @@ public class Maven2RepositoryMetadataResolverTest
assertDependency( dependencies.get( 9 ), "easymock", "easymockclassextension", "1.2", "test" );
}
+ // TODO: test snapshot, rest of artifacts
+ public void testGetArtifactMetadata()
+ throws Exception
+ {
+ Collection<ArtifactMetadata> springArtifacts = resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus",
+ "plexus-spring", "1.2" );
+ List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( springArtifacts );
+
+ assertEquals( 3, artifacts.size() );
+
+ ArtifactMetadata artifactMetadata = artifacts.get( 0 );
+ assertEquals( "plexus-spring-1.2-sources.jar", artifactMetadata.getId() );
+ MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 0, facet.getBuildNumber() );
+ assertNull( facet.getTimestamp() );
+ assertEquals( "sources", facet.getClassifier() );
+ // TODO
+// assertEquals( "java-source", facet.getType() );
+
+ artifactMetadata = artifacts.get( 1 );
+ assertEquals( "plexus-spring-1.2.jar", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 0, facet.getBuildNumber() );
+ assertNull( facet.getTimestamp() );
+ assertNull( facet.getClassifier() );
+ // TODO
+// assertEquals( "jar", facet.getType() );
+
+ artifactMetadata = artifacts.get( 2 );
+ assertEquals( "plexus-spring-1.2.pom", artifactMetadata.getId() );
+ facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+ assertEquals( 0, facet.getBuildNumber() );
+ assertNull( facet.getTimestamp() );
+ assertNull( facet.getClassifier() );
+ // TODO
+// assertEquals( "pom", facet.getType() );
+ }
+
private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )
{
assertDependency( dependency, groupId, artifactId, version, "compile" );
@@ -151,8 +191,8 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetProjectVersionMetadataForTimestampedSnapshot()
throws Exception
{
- ProjectVersionMetadata metadata =
- resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT" );
+ ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache",
+ "5-SNAPSHOT" );
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
assertEquals( "pom", facet.getPackaging() );
assertEquals( "http://www.apache.org/", metadata.getUrl() );
@@ -188,24 +228,24 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata()
throws Exception
{
- ProjectVersionMetadata metadata =
- resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT" );
+ FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata",
+ "1.0-SNAPSHOT" );
assertNull( metadata );
}
public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata()
throws Exception
{
- ProjectVersionMetadata metadata =
- resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata", "1.0-SNAPSHOT" );
+ FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata",
+ "1.0-SNAPSHOT" );
assertNull( metadata );
}
public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata()
throws Exception
{
- ProjectVersionMetadata metadata =
- resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata", "1.0-SNAPSHOT" );
+ FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata",
+ "1.0-SNAPSHOT" );
assertNull( metadata );
}
@@ -221,10 +261,11 @@ public class Maven2RepositoryMetadataResolverTest
}
catch ( MetadataResolutionException e )
{
- assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
- RepositoryProblemFacet facet =
- (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID,
- "com.example.test/invalid-pom/1.0" );
+ assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID,
+ RepositoryProblemFacet.FACET_ID ).isEmpty() );
+ RepositoryProblemFacet facet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID,
+ RepositoryProblemFacet.FACET_ID,
+ "com.example.test/invalid-pom/1.0" );
assertEquals( "invalid-pom", facet.getProblem() );
}
}
@@ -241,10 +282,11 @@ public class Maven2RepositoryMetadataResolverTest
}
catch ( MetadataResolutionException e )
{
- assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
- RepositoryProblemFacet facet =
- (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID,
- "com.example.test/mislocated-pom/1.0" );
+ assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID,
+ RepositoryProblemFacet.FACET_ID ).isEmpty() );
+ RepositoryProblemFacet facet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID,
+ RepositoryProblemFacet.FACET_ID,
+ "com.example.test/mislocated-pom/1.0" );
assertEquals( "mislocated-pom", facet.getProblem() );
}
}
@@ -254,14 +296,13 @@ public class Maven2RepositoryMetadataResolverTest
{
assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
- ProjectVersionMetadata metadata =
- resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" );
+ FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" );
assertNull( metadata );
assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
- RepositoryProblemFacet facet =
- (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID,
- "com.example.test/missing-pom/1.0" );
+ RepositoryProblemFacet facet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID,
+ RepositoryProblemFacet.FACET_ID,
+ "com.example.test/missing-pom/1.0" );
assertEquals( "missing-pom", facet.getProblem() );
}
@@ -280,12 +321,12 @@ public class Maven2RepositoryMetadataResolverTest
assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.getNamespaces( TEST_REPO_ID, "org" ) );
assertEquals( Arrays.asList( "archiva", "maven" ), resolver.getNamespaces( TEST_REPO_ID, "org.apache" ) );
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) );
- assertEquals( Arrays.asList( "plugins", "shared" ),
- resolver.getNamespaces( TEST_REPO_ID, "org.apache.maven" ) );
- assertEquals( Collections.<String>emptyList(),
- resolver.getNamespaces( TEST_REPO_ID, "org.apache.maven.plugins" ) );
- assertEquals( Collections.<String>emptyList(),
- resolver.getNamespaces( TEST_REPO_ID, "org.apache.maven.shared" ) );
+ assertEquals( Arrays.asList( "plugins", "shared" ), resolver.getNamespaces( TEST_REPO_ID,
+ "org.apache.maven" ) );
+ assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID,
+ "org.apache.maven.plugins" ) );
+ assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID,
+ "org.apache.maven.shared" ) );
assertEquals( Arrays.asList( "plexus" ), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus" ) );
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) );
@@ -303,45 +344,48 @@ public class Maven2RepositoryMetadataResolverTest
assertEquals( Arrays.asList( "archiva", "archiva-base", "archiva-common", "archiva-modules", "archiva-parent" ),
resolver.getProjects( TEST_REPO_ID, "org.apache.archiva" ) );
assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org.apache.maven" ) );
- assertEquals( Collections.<String>emptyList(),
- resolver.getProjects( TEST_REPO_ID, "org.apache.maven.plugins" ) );
- assertEquals( Arrays.asList( "maven-downloader" ),
- resolver.getProjects( TEST_REPO_ID, "org.apache.maven.shared" ) );
+ assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID,
+ "org.apache.maven.plugins" ) );
+ assertEquals( Arrays.asList( "maven-downloader" ), resolver.getProjects( TEST_REPO_ID,
+ "org.apache.maven.shared" ) );
}
public void testGetProjectVersions()
{
- assertEquals( Arrays.asList( "1.0-SNAPSHOT" ),
- resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", "incomplete-metadata" ) );
- assertEquals( Arrays.asList( "1.0-SNAPSHOT" ),
- resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", "malformed-metadata" ) );
- assertEquals( Arrays.asList( "1.0-SNAPSHOT" ),
- resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", "missing-metadata" ) );
- assertEquals( Arrays.asList( "1.0" ),
- resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", "invalid-pom" ) );
-
- assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache", "apache" ) );
-
- assertEquals( Arrays.asList( "1.2.1" ),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva" ) );
- assertEquals( Arrays.asList( "1.2.1" ),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-base" ) );
- assertEquals( Arrays.asList( "1.2.1" ),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-common" ) );
- assertEquals( Arrays.asList( "1.2.1" ),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-modules" ) );
- assertEquals( Arrays.asList( "3" ),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-parent" ) );
-
- assertEquals( Collections.<String>emptyList(),
- resolver.getProjectVersions( TEST_REPO_ID, "org.apache.maven.shared", "maven-downloader" ) );
+ assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
+ "incomplete-metadata" ) );
+ assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
+ "malformed-metadata" ) );
+ assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
+ "missing-metadata" ) );
+ assertEquals( Arrays.asList( "1.0" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
+ "invalid-pom" ) );
+
+ assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache",
+ "apache" ) );
+
+ assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
+ "archiva" ) );
+ assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
+ "archiva-base" ) );
+ assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
+ "archiva-common" ) );
+ assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
+ "archiva-modules" ) );
+ assertEquals( Arrays.asList( "3" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
+ "archiva-parent" ) );
+
+ assertEquals( Collections.<String>emptyList(), resolver.getProjectVersions( TEST_REPO_ID,
+ "org.apache.maven.shared",
+ "maven-downloader" ) );
}
public void testGetArtifacts()
{
- List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(
- resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ) );
+ List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID,
+ "org.codehaus.plexus",
+ "plexus-spring",
+ "1.2" ) );
assertEquals( 3, artifacts.size() );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{
@@ -359,10 +403,12 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetArtifactsFiltered()
{
- ExcludesFilter<String> filter =
- new ExcludesFilter<String>( Collections.singletonList( "plexus-spring-1.2.pom" ) );
- List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(
- resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) );
+ ExcludesFilter<String> filter = new ExcludesFilter<String>( Collections.singletonList(
+ "plexus-spring-1.2.pom" ) );
+ List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID,
+ "org.codehaus.plexus",
+ "plexus-spring",
+ "1.2", filter ) );
assertEquals( 2, artifacts.size() );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{
@@ -378,8 +424,10 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetArtifactsTimestampedSnapshots()
{
- List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(
- resolver.getArtifacts( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT" ) );
+ List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID,
+ "com.example.test",
+ "missing-metadata",
+ "1.0-SNAPSHOT" ) );
assertEquals( 1, artifacts.size() );
ArtifactMetadata artifact = artifacts.get( 0 );
diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
index 6565f7512..18cbdca20 100644
--- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java
@@ -423,6 +423,7 @@ public class FileMetadataRepository
String id = tok.nextToken();
ArtifactMetadata artifact = artifacts.get( id );
+ // TODO: facets (&test)
if ( artifact == null )
{
artifact = new ArtifactMetadata();
diff --git a/archiva-modules/plugins/problem-reports/pom.xml b/archiva-modules/plugins/problem-reports/pom.xml
index c1f39808d..5e64c86c5 100644
--- a/archiva-modules/plugins/problem-reports/pom.xml
+++ b/archiva-modules/plugins/problem-reports/pom.xml
@@ -57,7 +57,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
- <version>1.8.3</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/archiva-modules/plugins/problem-reports/src/test/resources/META-INF/spring-context.xml b/archiva-modules/plugins/problem-reports/src/test/resources/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest-context.xml
index 0aafa2680..0aafa2680 100644
--- a/archiva-modules/plugins/problem-reports/src/test/resources/META-INF/spring-context.xml
+++ b/archiva-modules/plugins/problem-reports/src/test/resources/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest-context.xml
diff --git a/archiva-modules/pom.xml b/archiva-modules/pom.xml
index 03c52a0d3..1ab9386fc 100644
--- a/archiva-modules/pom.xml
+++ b/archiva-modules/pom.xml
@@ -16,7 +16,9 @@
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
- --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>archiva</artifactId>
<groupId>org.apache.archiva</groupId>
@@ -34,6 +36,16 @@
<module>metadata</module>
<module>plugins</module>
</modules>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<build>
<pluginManagement>
<plugins>
@@ -82,13 +94,13 @@
</configuration>
</plugin>
-->
-<!-- TODO: OOME
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>1.1.1</version>
- </plugin>
--->
+ <!-- TODO: OOME
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ </plugin>
+ -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>