This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva.git


The following commit(s) were added to refs/heads/master by this push:
     new 84d9f57  Adding implementation of artifact
84d9f57 is described below

commit 84d9f5723fde9e72ab413d1ef739f1f728b84485
Author: Martin Stockhammer <marti...@apache.org>
AuthorDate: Wed Feb 12 21:47:11 2020 +0100

    Adding implementation of artifact
---
 .../archiva/repository/content/Artifact.java       |   6 -
 .../repository/content/base/ArchivaArtifact.java   | 200 +++++++++++++++++++++
 2 files changed, 200 insertions(+), 6 deletions(-)

diff --git 
a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/Artifact.java
 
b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/Artifact.java
index cd1f2e2..474f824 100644
--- 
a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/Artifact.java
+++ 
b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/content/Artifact.java
@@ -79,12 +79,6 @@ public interface Artifact extends ContentItem
     Version getVersion();
 
     /**
-     * Returns the project this artifact is part of.
-     * @return the project object
-     */
-    Project getProject();
-
-    /**
      * Returns the type of the artifact. The type is some hint about the usage 
of the artifact.
      * Implementations may always return a empty string, if it is not used.
      *
diff --git 
a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaArtifact.java
 
b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaArtifact.java
new file mode 100644
index 0000000..7ac99a7
--- /dev/null
+++ 
b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArchivaArtifact.java
@@ -0,0 +1,200 @@
+package org.apache.archiva.repository.content.base;
+
+/*
+ * 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.repository.content.Artifact;
+import org.apache.archiva.repository.content.Version;
+import org.apache.archiva.repository.storage.StorageAsset;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ *
+ * Base implementation of artifact. A builder is used to create instances.
+ *
+ * @author Martin Stockhammer <marti...@apache.org>
+ */
+public class ArchivaArtifact extends ArchivaContentItem implements Artifact
+{
+    private String namespace;
+    private String id;
+    private String artifactVersion;
+    private Version version;
+    private String type;
+    private String classifier;
+    private String remainder;
+    private String contentType;
+    private StorageAsset asset;
+
+    private ArchivaArtifact() {
+
+    }
+
+    @Override
+    public String getNamespace( )
+    {
+        return namespace;
+    }
+
+    @Override
+    public String getId( )
+    {
+        return id;
+    }
+
+    @Override
+    public String getArtifactVersion( )
+    {
+        return artifactVersion;
+    }
+
+    @Override
+    public Version getVersion( )
+    {
+        return version;
+    }
+
+    @Override
+    public String getType( )
+    {
+        return type;
+    }
+
+    @Override
+    public String getClassifier( )
+    {
+        return classifier;
+    }
+
+    @Override
+    public String getRemainder( )
+    {
+        return remainder;
+    }
+
+    @Override
+    public String getContentType( )
+    {
+        return contentType;
+    }
+
+    @Override
+    public StorageAsset getAsset( )
+    {
+        return asset;
+    }
+
+    public static ArtifactVersionBuilder withId(String id) {
+        return new Builder( ).withId( id );
+    }
+
+
+    public interface ArtifactVersionBuilder {
+        VersionBuilder withArtifactVersion( String version );
+    }
+    public interface VersionBuilder {
+        AssetBuilder withVersion( Version version );
+    }
+    public interface AssetBuilder {
+        Builder withAsset( StorageAsset asset );
+    }
+
+
+    public static class Builder implements ArtifactVersionBuilder, 
VersionBuilder,
+        AssetBuilder
+    {
+        ArchivaArtifact artifact = new ArchivaArtifact( );
+
+        public ArtifactVersionBuilder withId(String id) {
+            artifact.id = id;
+            return this;
+        }
+
+
+        @Override
+        public VersionBuilder withArtifactVersion( String version )
+        {
+            if ( StringUtils.isEmpty( version ) ) {
+                throw new IllegalArgumentException( "version may not be null 
or empty" );
+            }
+            artifact.artifactVersion = version;
+            return this;
+        }
+
+        @Override
+        public AssetBuilder withVersion( Version version )
+        {
+            if (version==null) {
+                throw new IllegalArgumentException( "version may not be null" 
);
+            }
+            artifact.version = version;
+            return this;
+        }
+
+        public Builder withAsset(StorageAsset asset) {
+            if (asset==null) {
+                throw new IllegalArgumentException( "Asset may not be null" );
+            }
+            artifact.asset = asset;
+            return this;
+        }
+
+        public Builder withNamespace(String namespace) {
+            artifact.namespace = namespace;
+            return this;
+        }
+
+        public Builder withType(String type) {
+            artifact.type = type;
+            return this;
+        }
+
+        public Builder withClassifier(String classifier) {
+            artifact.classifier = classifier;
+            return this;
+        }
+
+        public Builder withRemainder(String remainder) {
+            artifact.remainder = remainder;
+            return this;
+        }
+
+        public Builder withContentType(String contentType) {
+            artifact.contentType = contentType;
+            return this;
+        }
+
+        public ArchivaArtifact build() {
+            if (artifact.namespace==null) {
+                artifact.namespace = "";
+            }
+            if (artifact.classifier==null) {
+                artifact.classifier = "";
+            }
+            if (artifact.type == null)  {
+                artifact.type = "";
+            }
+            if (artifact.contentType==null) {
+                artifact.contentType = "";
+            }
+
+            return artifact;
+        }
+    }
+}

Reply via email to