import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
import java.time.ZonedDateTime;
import java.util.Collection;
import java.util.List;
* But for some backends there is no difference.
*
*/
+@ParametersAreNonnullByDefault
public interface MetadataRepository
{
* @param project the project metadata to create or update
* @throws MetadataRepositoryException if the update fails
*/
- void updateProject( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull ProjectMetadata project )
+ void updateProject( RepositorySession session, String repositoryId, ProjectMetadata project )
throws MetadataRepositoryException;
/**
* @param artifactMeta Information about the artifact itself.
* @throws MetadataRepositoryException if something goes wrong during update.
*/
- void updateArtifact( @Nonnull RepositorySession session, @Nonnull String repositoryId,
- @Nonnull String namespace, @Nonnull String projectId, @Nonnull String projectVersion,
- @Nonnull ArtifactMetadata artifactMeta )
+ void updateArtifact( RepositorySession session, String repositoryId,
+ String namespace, String projectId, String projectVersion,
+ ArtifactMetadata artifactMeta )
throws MetadataRepositoryException;
/**
* @param versionMetadata The metadata for the version
* @throws MetadataRepositoryException if something goes wrong during update
*/
- void updateProjectVersion( @Nonnull RepositorySession session, @Nonnull String repositoryId,
- @Nonnull String namespace, @Nonnull String projectId,
- @Nonnull ProjectVersionMetadata versionMetadata )
+ void updateProjectVersion( RepositorySession session, String repositoryId,
+ String namespace, String projectId,
+ ProjectVersionMetadata versionMetadata )
throws MetadataRepositoryException;
/**
* @param namespace The namespace ('.' separated)
* @throws MetadataRepositoryException if something goes wrong during update
*/
- void updateNamespace( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String namespace )
+ void updateNamespace( RepositorySession session, String repositoryId, String namespace )
throws MetadataRepositoryException;
/**
* @return The list of facet names, or an empty list, if there are no facets stored on this repository for the given facet id.
* @throws MetadataRepositoryException if something goes wrong
*/
- List<String> getMetadataFacets( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String facetId )
+ List<String> getMetadataFacets( RepositorySession session, String repositoryId, String facetId )
throws MetadataRepositoryException;
* @throws MetadataRepositoryException
* @since 3.0
*/
- <T extends MetadataFacet> Stream<T> getMetadataFacetStream( @Nonnull RepositorySession session,
- @Nonnull String repositoryId, @Nonnull Class<T> facetClazz)
+ <T extends MetadataFacet> Stream<T> getMetadataFacetStream( RepositorySession session,
+ String repositoryId, Class<T> facetClazz)
throws MetadataRepositoryException;
/**
* @throws MetadataRepositoryException
* @since 3.0
*/
- <T extends MetadataFacet> Stream<T> getMetadataFacetStream(@Nonnull RepositorySession session,
- @Nonnull String repositoryId, @Nonnull Class<T> facetClazz,
- @Nonnull QueryParameter queryParameter)
+ <T extends MetadataFacet> Stream<T> getMetadataFacetStream( RepositorySession session,
+ String repositoryId, Class<T> facetClazz,
+ QueryParameter queryParameter)
throws MetadataRepositoryException;
/**
* @throws MetadataRepositoryException if something goes wrong
* @since 1.4-M4
*/
- boolean hasMetadataFacet( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String facetId )
+ boolean hasMetadataFacet( RepositorySession session, String repositoryId, String facetId )
throws MetadataRepositoryException;
/**
* @return The facet values
* @throws MetadataRepositoryException if something goes wrong.
*/
- MetadataFacet getMetadataFacet( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String facetId,
- @Nonnull String name )
+ MetadataFacet getMetadataFacet( RepositorySession session, String repositoryId, String facetId,
+ String name )
throws MetadataRepositoryException;
/**
* @throws MetadataRepositoryException if the data cannot be retrieved from the backend
* @since 3.0
*/
- <T extends MetadataFacet> T getMetadataFacet(@Nonnull RepositorySession session, @Nonnull String repositoryId,
- @Nonnull Class<T> clazz, @Nonnull String name)
+ <T extends MetadataFacet> T getMetadataFacet( RepositorySession session, String repositoryId,
+ Class<T> clazz, String name)
throws MetadataRepositoryException;
/**
* @param metadataFacet The facet to add
* @throws MetadataRepositoryException if the facet cannot be stored.
*/
- void addMetadataFacet( @Nonnull RepositorySession session, @Nonnull String repositoryId,
- @Nonnull MetadataFacet metadataFacet )
+ void addMetadataFacet( RepositorySession session, String repositoryId,
+ MetadataFacet metadataFacet )
throws MetadataRepositoryException;
/**
* @param facetId The facet id
* @throws MetadataRepositoryException if the removal fails
*/
- void removeMetadataFacets( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String facetId )
+ void removeMetadataFacets( RepositorySession session, String repositoryId, String facetId )
throws MetadataRepositoryException;
/**
* @param facetId The facet id
* @param name The facet name or path
*/
- void removeMetadataFacet( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String facetId, @Nonnull String name )
+ void removeMetadataFacet( RepositorySession session, String repositoryId, String facetId, String name )
throws MetadataRepositoryException;
* uses default query parameters.
*
*/
- List<ArtifactMetadata> getArtifactsByDateRange( @Nonnull RepositorySession session, @Nonnull String repositoryId,
+ List<ArtifactMetadata> getArtifactsByDateRange( RepositorySession session, String repositoryId,
@Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime )
throws MetadataRepositoryException;
* @throws MetadataRepositoryException if the query fails.
* @since 3.0
*/
- List<ArtifactMetadata> getArtifactsByDateRange(@Nonnull RepositorySession session, @Nonnull String repositoryId,
+ List<ArtifactMetadata> getArtifactsByDateRange( RepositorySession session, String repositoryId,
@Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime,
- @Nonnull QueryParameter queryParameter )
+ QueryParameter queryParameter )
throws MetadataRepositoryException;
* @throws MetadataRepositoryException
* @since 3.0
*/
- Stream<ArtifactMetadata> getArtifactByDateRangeStream( @Nonnull RepositorySession session, @Nonnull String repositoryId,
+ Stream<ArtifactMetadata> getArtifactByDateRangeStream( RepositorySession session, String repositoryId,
@Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime )
throws MetadataRepositoryException;
* @throws MetadataRepositoryException
* @since 3.0
*/
- Stream<ArtifactMetadata> getArtifactByDateRangeStream( @Nonnull RepositorySession session, @Nonnull String repositoryId,
+ Stream<ArtifactMetadata> getArtifactByDateRangeStream( RepositorySession session, String repositoryId,
@Nullable ZonedDateTime startTime, @Nullable ZonedDateTime endTime,
- @Nonnull QueryParameter queryParameter)
+ QueryParameter queryParameter)
throws MetadataRepositoryException;
* @return The list of artifacts that match the given checksum.
* @throws MetadataRepositoryException
*/
- List<ArtifactMetadata> getArtifactsByChecksum(@Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull String checksum )
+ List<ArtifactMetadata> getArtifactsByChecksum( RepositorySession session, String repositoryId, String checksum )
throws MetadataRepositoryException;
/**
* @return a list of artifacts
* @throws MetadataRepositoryException
*/
- List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( @Nonnull RepositorySession session, @Nonnull String key, @Nonnull String value,
+ List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( RepositorySession session, String key, String value,
@Nullable String repositoryId )
throws MetadataRepositoryException;
* @return A stream of artifact metadata objects for each artifact found in the repository.
* @since 3.0
*/
- Stream<ArtifactMetadata> getArtifactStream( @Nonnull RepositorySession session, @Nonnull String repositoryId, @Nonnull QueryParameter queryParameter )
+ Stream<ArtifactMetadata> getArtifactStream( RepositorySession session, String repositoryId, QueryParameter queryParameter )
throws MetadataResolutionException;
/**
* @since 3.0
* @see #getArtifactStream(RepositorySession, String, QueryParameter)
*/
- Stream<ArtifactMetadata> getArtifactStream( @Nonnull RepositorySession session, @Nonnull String repositoryId)
+ Stream<ArtifactMetadata> getArtifactStream( RepositorySession session, String repositoryId)
throws MetadataResolutionException;
/**
* @since 3.0
* @throws MetadataResolutionException if there are no elements for the given artifact coordinates.
*/
- Stream<ArtifactMetadata> getArtifactStream( @Nonnull RepositorySession session, @Nonnull String repoId,
- @Nonnull String namespace, @Nonnull String projectId,
- @Nonnull String projectVersion, @Nonnull QueryParameter queryParameter )
+ Stream<ArtifactMetadata> getArtifactStream( RepositorySession session, String repoId,
+ String namespace, String projectId,
+ String projectVersion, QueryParameter queryParameter )
throws MetadataResolutionException;
/**
* @since 3.0
* @throws MetadataResolutionException if there are no elements for the given artifact coordinates.
*/
- Stream<ArtifactMetadata> getArtifactStream( @Nonnull RepositorySession session, @Nonnull String repoId,
- @Nonnull String namespace, @Nonnull String projectId,
- @Nonnull String projectVersion)
+ Stream<ArtifactMetadata> getArtifactStream( RepositorySession session, String repoId,
+ String namespace, String projectId,
+ String projectVersion)
throws MetadataResolutionException;
/**
* basically just checking it exists not complete data returned
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.metadata.QueryParameter;
-import org.apache.archiva.metadata.model.*;
-import org.apache.archiva.metadata.repository.*;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.CiManagement;
+import org.apache.archiva.metadata.model.Dependency;
+import org.apache.archiva.metadata.model.IssueManagement;
+import org.apache.archiva.metadata.model.License;
+import org.apache.archiva.metadata.model.MailingList;
+import org.apache.archiva.metadata.model.MetadataFacet;
+import org.apache.archiva.metadata.model.MetadataFacetFactory;
+import org.apache.archiva.metadata.model.Organization;
+import org.apache.archiva.metadata.model.ProjectMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
+import org.apache.archiva.metadata.model.Scm;
+import org.apache.archiva.metadata.repository.AbstractMetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.MetadataRepositoryException;
+import org.apache.archiva.metadata.repository.MetadataResolutionException;
+import org.apache.archiva.metadata.repository.MetadataService;
+import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.file.*;
+import java.nio.file.FileVisitOption;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+/**
+ * File implementation of the metadata repository. It uses property files in a separate directory tree.
+ * The implementation has no fulltext index. So fulltext queries are not supported.
+ *
+ * Some retrieval methods may not be very efficient.
+ */
+@ParametersAreNonnullByDefault
public class FileMetadataRepository
extends AbstractMetadataRepository implements MetadataRepository {
}
@Override
- public Stream<ArtifactMetadata> getArtifactStream( @Nonnull final RepositorySession session, @Nonnull final String repositoryId,
- @Nonnull QueryParameter queryParameter ) throws MetadataResolutionException
+ public Stream<ArtifactMetadata> getArtifactStream( final RepositorySession session, final String repositoryId,
+ QueryParameter queryParameter ) throws MetadataResolutionException
{
return getAllNamespacesStream( session, repositoryId ).filter( Objects::nonNull ).flatMap( ns ->