aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata/metadata-model-maven2
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-10-29 20:42:12 +0000
committerOlivier Lamy <olamy@apache.org>2012-10-29 20:42:12 +0000
commita586d56df251be5950ce8cd59cd8b22a5a516882 (patch)
treeaefb3c01ad85e6e90b6cc49eb60367cc2984a01b /archiva-modules/metadata/metadata-model-maven2
parent632257925a672a9634b2284b029f1b23c3eb997a (diff)
downloadarchiva-a586d56df251be5950ce8cd59cd8b22a5a516882.tar.gz
archiva-a586d56df251be5950ce8cd59cd8b22a5a516882.zip
[MRM-1704] Refactor to remove maven specific part from various repository/metadata apis
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1403491 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata/metadata-model-maven2')
-rw-r--r--archiva-modules/metadata/metadata-model-maven2/pom.xml63
-rw-r--r--archiva-modules/metadata/metadata-model-maven2/src/main/java/org/apache/archiva/metadata/model/maven2/MavenArtifactFacet.java140
2 files changed, 203 insertions, 0 deletions
diff --git a/archiva-modules/metadata/metadata-model-maven2/pom.xml b/archiva-modules/metadata/metadata-model-maven2/pom.xml
new file mode 100644
index 000000000..6c47c1a69
--- /dev/null
+++ b/archiva-modules/metadata/metadata-model-maven2/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>metadata</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.4-M4-SNAPSHOT</version>
+ </parent>
+ <artifactId>metadata-model-maven2</artifactId>
+ <packaging>bundle</packaging>
+ <name>Archiva Metadata :: Maven 2 Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.apache.archiva.metadata.model</Bundle-SymbolicName>
+ <Bundle-Version>${project.version}</Bundle-Version>
+ <Export-Package>
+ org.apache.archiva.metadata.model;version=${project.version};-split-package:=merge-first
+ </Export-Package>
+ <Import-Package>
+ javax.xml.bind.annotation,
+ org.apache.commons.lang
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/archiva-modules/metadata/metadata-model-maven2/src/main/java/org/apache/archiva/metadata/model/maven2/MavenArtifactFacet.java b/archiva-modules/metadata/metadata-model-maven2/src/main/java/org/apache/archiva/metadata/model/maven2/MavenArtifactFacet.java
new file mode 100644
index 000000000..6a88d6540
--- /dev/null
+++ b/archiva-modules/metadata/metadata-model-maven2/src/main/java/org/apache/archiva/metadata/model/maven2/MavenArtifactFacet.java
@@ -0,0 +1,140 @@
+package org.apache.archiva.metadata.model.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 org.apache.commons.lang.StringUtils;
+
+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()
+ {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put( "type", type );
+ if ( classifier != null )
+ {
+ properties.put( "classifier", classifier );
+ }
+ if ( timestamp != null )
+ {
+ properties.put( "timestamp", timestamp );
+ }
+ if ( buildNumber > 0 )
+ {
+ properties.put( "buildNumber", Integer.toString( buildNumber ) );
+ }
+ return properties;
+ }
+
+ public void fromProperties( Map<String, String> properties )
+ {
+ type = properties.get( "type" );
+ classifier = properties.get( "classifier" );
+ timestamp = properties.get( "timestamp" );
+ String buildNumber = properties.get( "buildNumber" );
+ if ( buildNumber != null )
+ {
+ this.buildNumber = Integer.parseInt( buildNumber );
+ }
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof MavenArtifactFacet ) )
+ {
+ return false;
+ }
+
+ MavenArtifactFacet that = (MavenArtifactFacet) o;
+
+ return StringUtils.equals( that.getClassifier(), this.classifier );
+ }
+
+}