1 package org.apache.archiva.repository.content;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.repository.UnsupportedRepositoryTypeException;
23 import org.apache.archiva.repository.storage.StorageAsset;
29 * Represents a artifact of a repository. This object contains unique coordinates of the
30 * artifact. A artifact has exactly one file representation in the repository.
31 * The artifact instance does not tell, if the file exists or is readable. It just
32 * keeps the coordinates and some meta information of the artifact.
34 * Artifact implementations should be immutable. The implementation must not always represent the current state of the
35 * corresponding storage asset (file). It is just a view of the attributes for a given point in time.
37 * Implementations must provide proper hash and equals methods.
40 * @author Martin Stockhammer <martin_s@apache.org>
42 public interface Artifact extends ContentItem
45 * The namespace is the location of the artifact.
46 * E.g. for maven artifacts it is the groupId.
47 * The namespace may be empty. Which means that is the base or root namespace.
49 * @return the namespace of the artifact. Never returns <code>null</code>.
51 String getNamespace();
54 * The artifact identifier. The ID is unique in a given namespace of a given repository.
55 * But there may exist artifacts with the same ID but different types, classifiers or extensions.
57 * Never returns <code>null</code> or a empty string.
59 * @return the identifier of the artifact. Never returns <code>null</code> or empty string
64 * The version string of the artifact. The version string is exactly the version that is attached
66 * The version string may be different to the version string returned by the attached {@link Version} object.
67 * E.g for maven artifacts the artifact version may be 1.3-20070725.210059-1 and the attached {@link Version} object
68 * has version 1.3-SNAPSHOT.
70 * @return the artifact version string
73 String getArtifactVersion();
76 * Returns the attached version this artifact is part of.
77 * @return the version object
82 * Returns the project this artifact is part of.
83 * @return the project object
88 * Returns the type of the artifact. The type is some hint about the usage of the artifact.
89 * Implementations may always return a empty string, if it is not used.
91 * @return the type of the artifact. Returns never <code>null</code>, but may be empty string
96 * A classifier that distinguishes artifacts.
97 * Implementations may always return a empty string, if it is not used.
99 * @return the classifier of the artifact. Returns never <code>null</code>, but may be empty string
101 String getClassifier();
104 * Short cut for the file name. Should always return the same value as the artifact name.
105 * @return the name of the file
107 default String getFileName() {
108 return getAsset( ).getName( );
112 * Returns the extension of the file. This method should always return the extension string after the last
115 * @return the file name extension
117 default String getExtension() {
118 final String name = getAsset().getName();
119 final int idx = name.lastIndexOf( '.' );
121 return name.substring( idx );
128 * This may be different from extension and gives the remainder that is used to build the file path from
129 * the artifact coordinates (namespace, id, version, classifier, type)
131 * @return the file name remainder
133 String getRemainder();
136 * Should return the mime type of the artifact.
138 * @return the mime type of the artifact.
140 String getContentType();
143 * Returns the storage representation of the artifact. The asset must not exist.
145 * @return the asset this artifact corresponds to.
147 StorageAsset getAsset();