From: Martin Stockhammer Date: Wed, 8 Nov 2017 21:59:33 +0000 (+0100) Subject: Rearranging modules and adding indexer api X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e2cdbc2b7229b4c141a61c8f9aa118304bee2632;p=archiva.git Rearranging modules and adding indexer api Combining the indexer api and repository api into archiva-repository-api They have bidirectional dependencies so they are put together in one module. Adding new classes for a generalized indexer api that will be used for interfaces and implementation independent tasks. --- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java index 59ca6b012..54e04dc9a 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java @@ -38,7 +38,7 @@ import org.apache.archiva.redback.components.registry.RegistryListener; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java index a09ff247d..8f537b56b 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java @@ -33,7 +33,7 @@ import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.RepositoryNotFoundException; import org.apache.archiva.repository.RepositoryRegistry; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.metadata.MetadataTools; import org.apache.archiva.repository.metadata.RepositoryMetadataException; import org.slf4j.Logger; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java index 181cbf45c..265c8e2e7 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java @@ -19,9 +19,6 @@ package org.apache.archiva.consumers.core.repository; * under the License. */ -import org.apache.archiva.admin.model.RepositoryAdminException; -import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.metadata.repository.MetadataRepository; @@ -33,16 +30,13 @@ import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.ReleaseScheme; -import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.RepositoryNotFoundException; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.events.RepositoryListener; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.metadata.MetadataTools; import org.apache.archiva.repository.metadata.RepositoryMetadataException; -import javax.inject.Inject; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java index 73fc456d0..2952f7fbc 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java @@ -27,7 +27,7 @@ import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.events.RepositoryListener; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.commons.lang.time.DateUtils; import java.io.IOException; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java index 98929bad8..bcecc8a8e 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java @@ -27,7 +27,7 @@ import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.events.RepositoryListener; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import java.nio.file.Files; import java.nio.file.Path; diff --git a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/LegacyConverterArtifactConsumer.java b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/LegacyConverterArtifactConsumer.java index 9cdde0ada..04653a5ac 100644 --- a/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/LegacyConverterArtifactConsumer.java +++ b/archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/LegacyConverterArtifactConsumer.java @@ -32,7 +32,7 @@ import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; diff --git a/archiva-modules/archiva-base/archiva-indexer-api/pom.xml b/archiva-modules/archiva-base/archiva-indexer-api/pom.xml deleted file mode 100644 index 5aec104c3..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - org.apache.archiva - archiva-base - 3.0.0-SNAPSHOT - - 4.0.0 - archiva-indexer-api - bundle - Archiva Base :: Indexer API - - - - org.apache.archiva - archiva-common - - - - commons-lang - commons-lang - - - org.apache.archiva - archiva-model - - - - - - - org.apache.rat - apache-rat-plugin - - - src/test/maven-search-test-repo*/** - src/test/repo-release*/** - - - - - - - - org.apache.felix - maven-bundle-plugin - - - org.apache.archiva.indexer.api - ${project.version} - - org.apache.archiva.indexer.*;version=${project.version};-split-package:=merge-first - - - javax.annotation, - javax.inject, - org.apache.commons.lang*;version="[2.4,3)", - org.slf4j;resolution:=optional - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${redbackTestJdbcUrl} - ${redbackTestJdbcDriver} - mock - ${openjpa.Log} - - - - - - diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java deleted file mode 100644 index 39c32daf6..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.apache.archiva.indexer.search; -/* - * 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.model.ArchivaArtifactModel; -import org.apache.archiva.model.ArtifactReference; - -import java.util.Map; - -/** - * @author Olivier Lamy - * @since 1.4-M1 - */ -public interface ArtifactInfoFilter -{ - boolean addArtifactInResult( ArchivaArtifactModel artifact, Map currentResult ); -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java deleted file mode 100644 index 272561b32..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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.List; -import java.util.Set; - - -public interface RepositorySearch -{ - /** - * Quick search by won't return artifact with file extension pom - * - * @param principal - * @param selectedRepos - * @param term - * @param limits - * @param previousSearchTerms - * @return - */ - SearchResults search( String principal, List selectedRepos, String term, SearchResultLimits limits, - List previousSearchTerms ) - throws RepositorySearchException; - - /** - * Advanced search. - * - * @param principal - * @param searchFields - * @param limits - * @return - */ - SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits ) - throws RepositorySearchException; - - Collection getAllGroupIds( String principal, List selectedRepos ) - throws RepositorySearchException; - - Set getRemoteIndexingContextIds( String managedRepoId ) - throws RepositorySearchException; -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java deleted file mode 100644 index e3da55107..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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. - */ - -public class RepositorySearchException - extends Exception -{ - public RepositorySearchException() - { - super(); - } - - public RepositorySearchException( String msg ) - { - super( msg ); - } - - public RepositorySearchException( Throwable e ) - { - super( e ); - } - - public RepositorySearchException( String msg, Throwable e ) - { - super( msg, e ); - } -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java deleted file mode 100644 index e5844a765..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java +++ /dev/null @@ -1,324 +0,0 @@ -package org.apache.archiva.indexer.search; - -import java.util.ArrayList; -import java.util.List; - -/* - * 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. - */ - -public class SearchFields -{ - /** - * groupId - */ - private String groupId; - - /** - * artifactId - */ - private String artifactId; - - /** - * version - */ - private String version; - - /** - * packaging (jar, war, pom, etc.) - */ - private String packaging; - - /** - * class name or package name - */ - private String className; - - /** - * repositories - */ - private List repositories = new ArrayList<>(); - - - /** - * contains osgi metadata Bundle-Version if available - * - * @since 1.4-M1 - */ - private String bundleVersion; - - /** - * contains osgi metadata Bundle-SymbolicName if available - * - * @since 1.4-M1 - */ - private String bundleSymbolicName; - - /** - * contains osgi metadata Export-Package if available - * - * @since 1.4-M1 - */ - private String bundleExportPackage; - - /** - * contains osgi metadata import package if available - * - * @since 1.4-M1 - */ - private String bundleImportPackage; - - /** - * contains osgi metadata name if available - * - * @since 1.4-M1 - */ - private String bundleName; - - /** - * contains osgi metadata Export-Service if available - * - * @since 1.4-M1 - */ - private String bundleExportService; - - - /** - * contains osgi metadata Require-Bundle if available - * - * @since 1.4-M3 - */ - private String bundleRequireBundle; - - /** - * not return artifact with file extension pom - * - * @since 1.4-M2 - */ - private boolean includePomArtifacts = false; - - private String classifier; - - /** - * we use exact String matching search - * - * @since 2.1.0 - */ - private boolean exactSearch = false; - - public SearchFields() - { - // no op - } - - public SearchFields( String groupId, String artifactId, String version, String packaging, String className, - List repositories ) - { - this.groupId = groupId; - this.artifactId = artifactId; - this.version = version; - this.packaging = packaging; - this.className = className; - this.repositories = repositories; - } - - public String getGroupId() - { - return groupId; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public String getPackaging() - { - return packaging; - } - - public void setPackaging( String packaging ) - { - this.packaging = packaging; - } - - public String getClassName() - { - return className; - } - - public void setClassName( String className ) - { - this.className = className; - } - - public List getRepositories() - { - return repositories; - } - - public void setRepositories( List repositories ) - { - this.repositories = repositories; - } - - - public String getBundleVersion() - { - return bundleVersion; - } - - public void setBundleVersion( String bundleVersion ) - { - this.bundleVersion = bundleVersion; - } - - public String getBundleSymbolicName() - { - return bundleSymbolicName; - } - - public void setBundleSymbolicName( String bundleSymbolicName ) - { - this.bundleSymbolicName = bundleSymbolicName; - } - - public String getBundleExportPackage() - { - return bundleExportPackage; - } - - public void setBundleExportPackage( String bundleExportPackage ) - { - this.bundleExportPackage = bundleExportPackage; - } - - public String getBundleExportService() - { - return bundleExportService; - } - - public void setBundleExportService( String bundleExportService ) - { - this.bundleExportService = bundleExportService; - } - - public String getClassifier() - { - return classifier; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public String getBundleImportPackage() - { - return bundleImportPackage; - } - - public void setBundleImportPackage( String bundleImportPackage ) - { - this.bundleImportPackage = bundleImportPackage; - } - - public String getBundleName() - { - return bundleName; - } - - public void setBundleName( String bundleName ) - { - this.bundleName = bundleName; - } - - public boolean isIncludePomArtifacts() - { - return includePomArtifacts; - } - - public void setIncludePomArtifacts( boolean includePomArtifacts ) - { - this.includePomArtifacts = includePomArtifacts; - } - - public String getBundleRequireBundle() - { - return bundleRequireBundle; - } - - public void setBundleRequireBundle( String bundleRequireBundle ) - { - this.bundleRequireBundle = bundleRequireBundle; - } - - public boolean isExactSearch() - { - return exactSearch; - } - - public void setExactSearch( boolean exactSearch ) - { - this.exactSearch = exactSearch; - } - - @Override - public String toString() - { - final StringBuilder sb = new StringBuilder(); - sb.append( "SearchFields" ); - sb.append( "{groupId='" ).append( groupId ).append( '\'' ); - sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); - sb.append( ", version='" ).append( version ).append( '\'' ); - sb.append( ", packaging='" ).append( packaging ).append( '\'' ); - sb.append( ", className='" ).append( className ).append( '\'' ); - sb.append( ", repositories=" ).append( repositories ); - sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); - sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); - sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); - sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); - sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); - sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); - sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); - sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); - sb.append( ", classifier='" ).append( classifier ).append( '\'' ); - sb.append( '}' ); - return sb.toString(); - } -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java deleted file mode 100644 index a493431c8..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java +++ /dev/null @@ -1,435 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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.ArrayList; -import java.util.List; - -/** - * SearchResultHit - * - */ -public class SearchResultHit -{ - // The (optional) context for this result. - private String context; - - // Basic hit, direct to non-artifact resource. - private String url; - - // Advanced hit, reference to groupId. - private String groupId; - - // Advanced hit, reference to artifactId. - private String artifactId; - - private String repositoryId = ""; - - private List versions = new ArrayList<>(); - - private String packaging; - - /** - * Plugin goal prefix (only if packaging is "maven-plugin") - */ - private String prefix; - - /** - * Plugin goals (only if packaging is "maven-plugin") - */ - private List goals; - - /** - * contains osgi metadata Bundle-Version if available - * - * @since 1.4-M1 - */ - private String bundleVersion; - - /** - * contains osgi metadata Bundle-SymbolicName if available - * - * @since 1.4-M1 - */ - private String bundleSymbolicName; - - /** - * contains osgi metadata Export-Package if available - * - * @since 1.4-M1 - */ - private String bundleExportPackage; - - /** - * contains osgi metadata Export-Service if available - * - * @since 1.4-M1 - */ - private String bundleExportService; - - /** - * contains osgi metadata Bundle-Description if available - * - * @since 1.4-M1 - */ - private String bundleDescription; - - /** - * contains osgi metadata Bundle-Name if available - * - * @since 1.4-M1 - */ - private String bundleName; - - /** - * contains osgi metadata Bundle-License if available - * - * @since 1.4-M1 - */ - private String bundleLicense; - - /** - * contains osgi metadata Bundle-DocURL if available - * - * @since 1.4-M1 - */ - private String bundleDocUrl; - - /** - * contains osgi metadata Import-Package if available - * - * @since 1.4-M1 - */ - private String bundleImportPackage; - - /** - * contains osgi metadata Require-Bundle if available - * - * @since 1.4-M1 - */ - private String bundleRequireBundle; - - private String classifier; - - /** - * file extension of the search result - * @since 1.4-M2 - */ - private String fileExtension; - - public String getContext() - { - return context; - } - - public void setContext( String context ) - { - this.context = context; - } - - public String getUrl() - { - return url; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public String getUrlFilename() - { - return this.url.substring( this.url.lastIndexOf( '/' ) ); - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getGroupId() - { - return groupId; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public List getVersions() - { - return versions; - } - - public void setVersions( List versions ) - { - this.versions = versions; - } - - public String getRepositoryId() - { - return repositoryId; - } - - public void setRepositoryId( String repositoryId ) - { - this.repositoryId = repositoryId; - } - - public void addVersion( String version ) - { - versions.add( version ); - } - - public String getBundleVersion() - { - return bundleVersion; - } - - public void setBundleVersion( String bundleVersion ) - { - this.bundleVersion = bundleVersion; - } - - public String getBundleSymbolicName() - { - return bundleSymbolicName; - } - - public void setBundleSymbolicName( String bundleSymbolicName ) - { - this.bundleSymbolicName = bundleSymbolicName; - } - - public String getBundleExportPackage() - { - return bundleExportPackage; - } - - public void setBundleExportPackage( String bundleExportPackage ) - { - this.bundleExportPackage = bundleExportPackage; - } - - public String getBundleExportService() - { - return bundleExportService; - } - - public void setBundleExportService( String bundleExportService ) - { - this.bundleExportService = bundleExportService; - } - - public String getPrefix() - { - return prefix; - } - - public void setPrefix( String prefix ) - { - this.prefix = prefix; - } - - public List getGoals() - { - return goals; - } - - public void setGoals( List goals ) - { - this.goals = goals; - } - - public String getBundleDescription() - { - return bundleDescription; - } - - public void setBundleDescription( String bundleDescription ) - { - this.bundleDescription = bundleDescription; - } - - public String getBundleName() - { - return bundleName; - } - - public void setBundleName( String bundleName ) - { - this.bundleName = bundleName; - } - - public String getBundleLicense() - { - return bundleLicense; - } - - public void setBundleLicense( String bundleLicense ) - { - this.bundleLicense = bundleLicense; - } - - public String getBundleDocUrl() - { - return bundleDocUrl; - } - - public void setBundleDocUrl( String bundleDocUrl ) - { - this.bundleDocUrl = bundleDocUrl; - } - - public String getBundleImportPackage() - { - return bundleImportPackage; - } - - public void setBundleImportPackage( String bundleImportPackage ) - { - this.bundleImportPackage = bundleImportPackage; - } - - public String getBundleRequireBundle() - { - return bundleRequireBundle; - } - - public void setBundleRequireBundle( String bundleRequireBundle ) - { - this.bundleRequireBundle = bundleRequireBundle; - } - - public String getPackaging() - { - return packaging; - } - - public void setPackaging( String packaging ) - { - this.packaging = packaging; - } - - public String getType() - { - return getPackaging(); - } - - public String getClassifier() - { - return classifier; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public String getFileExtension() - { - return fileExtension; - } - - public void setFileExtension( String fileExtension ) - { - this.fileExtension = fileExtension; - } - - @Override - public String toString() - { - final StringBuilder sb = new StringBuilder(); - sb.append( "SearchResultHit" ); - sb.append( "{context='" ).append( context ).append( '\'' ); - sb.append( ", url='" ).append( url ).append( '\'' ); - sb.append( ", groupId='" ).append( groupId ).append( '\'' ); - sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); - sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' ); - sb.append( ", versions=" ).append( versions ); - sb.append( ", packaging='" ).append( packaging ).append( '\'' ); - sb.append( ", prefix='" ).append( prefix ).append( '\'' ); - sb.append( ", goals=" ).append( goals ); - sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); - sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); - sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); - sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); - sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' ); - sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); - sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' ); - sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' ); - sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); - sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); - sb.append( ", classifier='" ).append( classifier ).append( '\'' ); - sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' ); - sb.append( '}' ); - return sb.toString(); - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || getClass() != o.getClass() ) - { - return false; - } - - SearchResultHit that = (SearchResultHit) o; - - if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null ) - { - return false; - } - if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null ) - { - return false; - } - if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null ) - { - return false; - } - if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null ) - { - return false; - } - - return true; - } - - @Override - public int hashCode() - { - int result = groupId != null ? groupId.hashCode() : 0; - result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 ); - result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 ); - result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 ); - return result; - } -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java deleted file mode 100644 index 967ecc5ae..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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. - */ - -/** - * SearchResultLimits - used to provide the search some limits on how the results are returned. - * This can provide paging for the result - */ -public class SearchResultLimits -{ - /** - * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES. - * USE WITH CAUTION!! - */ - public static final int ALL_PAGES = ( -1 ); - - private int pageSize = 30; - - private int selectedPage = 0; - - /** - * @param selectedPage page selected use -1 for all pages - */ - public SearchResultLimits( int selectedPage ) - { - this.selectedPage = selectedPage; - } - - /** - * @param pageSize number of groupId:artifact per page - * @param selectedPage page selected use -1 for all pages - * @since 1.4-M4 - */ - public SearchResultLimits( int pageSize, int selectedPage ) - { - this.pageSize = pageSize; - this.selectedPage = selectedPage; - } - - public int getPageSize() - { - return pageSize; - } - - /** - * Set page size for maximum # of hits to return per page. - * - * @param pageSize size of page by # of hits. - */ - public void setPageSize( int pageSize ) - { - this.pageSize = pageSize; - } - - public int getSelectedPage() - { - return selectedPage; - } - - public void setSelectedPage( int selectedPage ) - { - this.selectedPage = selectedPage; - } - - @Override - public String toString() - { - return "SearchResultLimits{" + "pageSize=" + pageSize + ", selectedPage=" + selectedPage + '}'; - } -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java deleted file mode 100644 index 9dc650fdc..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * SearchResults - * - */ -public class SearchResults -{ - private Map hits = new HashMap<>(); - - private int totalHits; - - private int totalHitsMapSize; - - private int returnedHitsCount; - - private SearchResultLimits limits; - - public SearchResults() - { - /* do nothing */ - } - - // for new RepositorySearch - public void addHit( String id, SearchResultHit hit ) - { - hits.put( id, hit ); - } - - /** - * Get the list of {@link SearchResultHit} objects. - * - * @return the list of {@link SearchResultHit} objects. - */ - public List getHits() - { - return new ArrayList<>( hits.values() ); - } - - /** - * see SearchUtil on how to generate the key - * - * @param key - * @return - */ - public SearchResultHit getSearchResultHit( String key ) - { - return hits.get( key ); - } - - public Map getHitsMap() - { - return hits; - } - - public boolean isEmpty() - { - return hits.isEmpty(); - } - - public SearchResultLimits getLimits() - { - return limits; - } - - public void setLimits( SearchResultLimits limits ) - { - this.limits = limits; - } - - public int getTotalHits() - { - return totalHits; - } - - public void setTotalHits( int totalHits ) - { - this.totalHits = totalHits; - } - - /** - * @return - * @since 1.4-M1 - */ - public int getReturnedHitsCount() - { - return returnedHitsCount; - } - - /** - * @param returnedHitsCount - * @since 1.4-M1 - */ - public void setReturnedHitsCount( int returnedHitsCount ) - { - this.returnedHitsCount = returnedHitsCount; - } - - /** - * @return - * @since 1.4-M1 - */ - public int getTotalHitsMapSize() - { - return totalHitsMapSize; - } - - /** - * @param totalHitsMapSize - * @since 1.4-M1 - */ - public void setTotalHitsMapSize( int totalHitsMapSize ) - { - this.totalHitsMapSize = totalHitsMapSize; - } - - @Override - public String toString() - { - return "SearchResults{" + "hits=" + hits + ", totalHits=" + totalHits + ", returnedHitsCount=" - + returnedHitsCount + ", limits=" + limits + '}'; - } -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java deleted file mode 100644 index 0a0c922ee..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.archiva.indexer.util; - -/* - * 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.commons.lang.StringUtils; - -/** - * SearchUtil - utility class for search. - */ -public class SearchUtil -{ - public static String getHitId( String groupId, String artifactId, String classifier, String packaging ) - { - return ( StringUtils.isBlank( groupId ) ? "" : StringUtils.trim( groupId ) ) + ":" // - + ( StringUtils.isBlank( artifactId ) ? "" : StringUtils.trim( artifactId ) ) + ":" // - + ( StringUtils.isBlank( classifier ) ? "" : StringUtils.trim( classifier ) ) + ":" // - + ( StringUtils.isBlank( packaging ) ? "" : StringUtils.trim( packaging ) ); - } -} diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml deleted file mode 100644 index ce334de40..000000000 --- a/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index ab0d89792..9634b7c75 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -42,12 +42,6 @@ org.apache.archiva archiva-repository-layer - - org.apache.archiva - archiva-indexer-api - - - org.springframework spring-context diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java index 614a5fbd8..9137993f8 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java @@ -26,7 +26,7 @@ import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy; import org.apache.archiva.policies.ProxyDownloadException; import org.apache.archiva.policies.ReleasesPolicy; import org.apache.archiva.policies.SnapshotsPolicy; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.authorization.AuthorizationException; diff --git a/archiva-modules/archiva-base/archiva-repository-api/pom.xml b/archiva-modules/archiva-base/archiva-repository-api/pom.xml new file mode 100644 index 000000000..168426c13 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/pom.xml @@ -0,0 +1,107 @@ + + + + + + org.apache.archiva + archiva-base + 3.0.0-SNAPSHOT + + 4.0.0 + archiva-repository-api + bundle + Archiva Base :: Repository API + + + + org.apache.archiva + archiva-common + + + + commons-lang + commons-lang + + + org.apache.archiva + archiva-model + + + org.apache.archiva + archiva-configuration + + + org.springframework + spring-context + + + + + + + org.apache.rat + apache-rat-plugin + + + src/test/maven-search-test-repo*/** + src/test/repo-release*/** + + + + + + + + org.apache.felix + maven-bundle-plugin + + + org.apache.archiva.indexer.api + ${project.version} + + org.apache.archiva.indexer.*;version=${project.version};-split-package:=merge-first + + + javax.annotation, + javax.inject, + org.apache.commons.lang*;version="[2.4,3)", + org.slf4j;resolution:=optional + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} + mock + ${openjpa.Log} + + + + + + diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java new file mode 100644 index 000000000..d8299839b --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexManager.java @@ -0,0 +1,71 @@ +package org.apache.archiva.indexer; + +/* + * 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.model.ArtifactReference; +import org.apache.archiva.repository.RepositoryType; + +import java.net.URI; + +public interface ArchivaIndexManager { + + /** + * Compresses the index to a more dense packed format. + * @param context + */ + void pack(ArchivaIndexingContext context); + + /** + * Rescans the whole repository, this index is associated to. + * @param context + * @param update + */ + void scan(ArchivaIndexingContext context, boolean update); + + /** + * Updates the index from the remote url. + * @param context + * @param remoteUpdateUri + * @param fullUpdate + */ + void update(ArchivaIndexingContext context, URI remoteUpdateUri, boolean fullUpdate); + + /** + * Adds a artifact to the index. + * @param context + * @param artifactReference + */ + void addArtifactToIndex(ArchivaIndexingContext context, ArtifactReference artifactReference); + + /** + * Removes a artifact from the index. + * @param context + * @param artifactReference + */ + void removeArtifactFromIndex(ArchivaIndexingContext context, ArtifactReference artifactReference); + + + /** + * Returns true, if this manager is able to apply the index actions for the given repository type. + * @param type + * @return + */ + boolean supportsRepository(RepositoryType type); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java new file mode 100644 index 000000000..23496e779 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/ArchivaIndexingContext.java @@ -0,0 +1,130 @@ +package org.apache.archiva.indexer; + +/* + * 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.Repository; +import org.apache.archiva.repository.RepositoryType; + +import java.io.IOException; +import java.net.URI; +import java.time.LocalDateTime; +import java.util.Set; + +/** + * This represents a indexing context that is used to manage the index of a certain repository. + * + */ +public interface ArchivaIndexingContext { + + /** + * The identifier of the context + * @return + */ + String getId(); + + /** + * Returns the repository this index context is associated to. + * @return + */ + Repository getRepository(); + + /** + * The path where the index is stored. + * @return + */ + URI getPath(); + + /** + * Returns true, if the index has no entries or is not initialized. + * @return + */ + boolean isEmpty(); + + /** + * Writes the last changes to the index. + * @throws IOException + */ + void commit() throws IOException; + + /** + * Throws away the last changes. + * @throws IOException + */ + void rollback() throws IOException; + + /** + * Optimizes the index + * @throws IOException + */ + void optimize() throws IOException; + + /** + * Closes any resources, this context has open. + * @param deleteFiles True, if the index files should be deleted. + * @throws IOException + */ + void close(boolean deleteFiles) throws IOException; + + /** + * Removes all entries from the index. After this method finished, + * isEmpty() should return true. + * @throws IOException + */ + void purge() throws IOException; + + /** + * Returns true, if this index implementation has support for the given repository specific + * implementation class. + * @param clazz + * @return + */ + boolean supports(Class clazz); + + /** + * Returns the repository specific implementation of the index. E.g. the maven index class. + * @param clazz the specific class + * @return the instance of the given class representing this index + * @throws UnsupportedOperationException if the implementation is not supported + */ + T getBaseContext(Class clazz) throws UnsupportedOperationException; + + + + /** + * Returns the list of groups that are assigned to this index + * @return + */ + Set getGroups(); + + /** + * Updates the timestamp of the index. + * @param save + * @throws IOException + */ + void updateTimestamp(boolean save) throws IOException; + + /** + * Updates the timestamp with the given time. + * @param save + * @param time + * @throws IOException + */ + void updateTimestamp(boolean save, LocalDateTime time) throws IOException; +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/IndexManagerFactory.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/IndexManagerFactory.java new file mode 100644 index 000000000..3eb3a14fe --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/IndexManagerFactory.java @@ -0,0 +1,53 @@ +package org.apache.archiva.indexer; + +/* + * 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.RepositoryType; +import org.apache.archiva.repository.UnsupportedRepositoryTypeException; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import java.util.HashMap; +import java.util.Map; + +/** + * This factory is used to get a index manager for a certain repository type. + */ +@Service("indexerManagerFactory") +public class IndexManagerFactory { + + Map managers= new HashMap<>(); + + @Inject + ApplicationContext applicationContext; + + ArchivaIndexManager getIndexManager(RepositoryType type) { + if (managers.containsKey(type)) { + return managers.get(type); + } else { + ArchivaIndexManager manager = applicationContext.getBeansOfType(ArchivaIndexManager.class).values().stream(). + filter(m -> m.supportsRepository(type)). + findFirst().orElseThrow(() -> new UnsupportedRepositoryTypeException(type)); + managers.put(type, manager); + return manager; + } + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java new file mode 100644 index 000000000..39c32daf6 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java @@ -0,0 +1,33 @@ +package org.apache.archiva.indexer.search; +/* + * 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.model.ArchivaArtifactModel; +import org.apache.archiva.model.ArtifactReference; + +import java.util.Map; + +/** + * @author Olivier Lamy + * @since 1.4-M1 + */ +public interface ArtifactInfoFilter +{ + boolean addArtifactInResult( ArchivaArtifactModel artifact, Map currentResult ); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java new file mode 100644 index 000000000..272561b32 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java @@ -0,0 +1,59 @@ +package org.apache.archiva.indexer.search; + +/* + * 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.List; +import java.util.Set; + + +public interface RepositorySearch +{ + /** + * Quick search by won't return artifact with file extension pom + * + * @param principal + * @param selectedRepos + * @param term + * @param limits + * @param previousSearchTerms + * @return + */ + SearchResults search( String principal, List selectedRepos, String term, SearchResultLimits limits, + List previousSearchTerms ) + throws RepositorySearchException; + + /** + * Advanced search. + * + * @param principal + * @param searchFields + * @param limits + * @return + */ + SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits ) + throws RepositorySearchException; + + Collection getAllGroupIds( String principal, List selectedRepos ) + throws RepositorySearchException; + + Set getRemoteIndexingContextIds( String managedRepoId ) + throws RepositorySearchException; +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java new file mode 100644 index 000000000..e3da55107 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java @@ -0,0 +1,44 @@ +package org.apache.archiva.indexer.search; + +/* + * 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. + */ + +public class RepositorySearchException + extends Exception +{ + public RepositorySearchException() + { + super(); + } + + public RepositorySearchException( String msg ) + { + super( msg ); + } + + public RepositorySearchException( Throwable e ) + { + super( e ); + } + + public RepositorySearchException( String msg, Throwable e ) + { + super( msg, e ); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java new file mode 100644 index 000000000..e5844a765 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java @@ -0,0 +1,324 @@ +package org.apache.archiva.indexer.search; + +import java.util.ArrayList; +import java.util.List; + +/* + * 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. + */ + +public class SearchFields +{ + /** + * groupId + */ + private String groupId; + + /** + * artifactId + */ + private String artifactId; + + /** + * version + */ + private String version; + + /** + * packaging (jar, war, pom, etc.) + */ + private String packaging; + + /** + * class name or package name + */ + private String className; + + /** + * repositories + */ + private List repositories = new ArrayList<>(); + + + /** + * contains osgi metadata Bundle-Version if available + * + * @since 1.4-M1 + */ + private String bundleVersion; + + /** + * contains osgi metadata Bundle-SymbolicName if available + * + * @since 1.4-M1 + */ + private String bundleSymbolicName; + + /** + * contains osgi metadata Export-Package if available + * + * @since 1.4-M1 + */ + private String bundleExportPackage; + + /** + * contains osgi metadata import package if available + * + * @since 1.4-M1 + */ + private String bundleImportPackage; + + /** + * contains osgi metadata name if available + * + * @since 1.4-M1 + */ + private String bundleName; + + /** + * contains osgi metadata Export-Service if available + * + * @since 1.4-M1 + */ + private String bundleExportService; + + + /** + * contains osgi metadata Require-Bundle if available + * + * @since 1.4-M3 + */ + private String bundleRequireBundle; + + /** + * not return artifact with file extension pom + * + * @since 1.4-M2 + */ + private boolean includePomArtifacts = false; + + private String classifier; + + /** + * we use exact String matching search + * + * @since 2.1.0 + */ + private boolean exactSearch = false; + + public SearchFields() + { + // no op + } + + public SearchFields( String groupId, String artifactId, String version, String packaging, String className, + List repositories ) + { + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + this.packaging = packaging; + this.className = className; + this.repositories = repositories; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + public String getPackaging() + { + return packaging; + } + + public void setPackaging( String packaging ) + { + this.packaging = packaging; + } + + public String getClassName() + { + return className; + } + + public void setClassName( String className ) + { + this.className = className; + } + + public List getRepositories() + { + return repositories; + } + + public void setRepositories( List repositories ) + { + this.repositories = repositories; + } + + + public String getBundleVersion() + { + return bundleVersion; + } + + public void setBundleVersion( String bundleVersion ) + { + this.bundleVersion = bundleVersion; + } + + public String getBundleSymbolicName() + { + return bundleSymbolicName; + } + + public void setBundleSymbolicName( String bundleSymbolicName ) + { + this.bundleSymbolicName = bundleSymbolicName; + } + + public String getBundleExportPackage() + { + return bundleExportPackage; + } + + public void setBundleExportPackage( String bundleExportPackage ) + { + this.bundleExportPackage = bundleExportPackage; + } + + public String getBundleExportService() + { + return bundleExportService; + } + + public void setBundleExportService( String bundleExportService ) + { + this.bundleExportService = bundleExportService; + } + + public String getClassifier() + { + return classifier; + } + + public void setClassifier( String classifier ) + { + this.classifier = classifier; + } + + public String getBundleImportPackage() + { + return bundleImportPackage; + } + + public void setBundleImportPackage( String bundleImportPackage ) + { + this.bundleImportPackage = bundleImportPackage; + } + + public String getBundleName() + { + return bundleName; + } + + public void setBundleName( String bundleName ) + { + this.bundleName = bundleName; + } + + public boolean isIncludePomArtifacts() + { + return includePomArtifacts; + } + + public void setIncludePomArtifacts( boolean includePomArtifacts ) + { + this.includePomArtifacts = includePomArtifacts; + } + + public String getBundleRequireBundle() + { + return bundleRequireBundle; + } + + public void setBundleRequireBundle( String bundleRequireBundle ) + { + this.bundleRequireBundle = bundleRequireBundle; + } + + public boolean isExactSearch() + { + return exactSearch; + } + + public void setExactSearch( boolean exactSearch ) + { + this.exactSearch = exactSearch; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "SearchFields" ); + sb.append( "{groupId='" ).append( groupId ).append( '\'' ); + sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); + sb.append( ", version='" ).append( version ).append( '\'' ); + sb.append( ", packaging='" ).append( packaging ).append( '\'' ); + sb.append( ", className='" ).append( className ).append( '\'' ); + sb.append( ", repositories=" ).append( repositories ); + sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); + sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); + sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); + sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); + sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); + sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); + sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); + sb.append( ", classifier='" ).append( classifier ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java new file mode 100644 index 000000000..a493431c8 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java @@ -0,0 +1,435 @@ +package org.apache.archiva.indexer.search; + +/* + * 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.ArrayList; +import java.util.List; + +/** + * SearchResultHit + * + */ +public class SearchResultHit +{ + // The (optional) context for this result. + private String context; + + // Basic hit, direct to non-artifact resource. + private String url; + + // Advanced hit, reference to groupId. + private String groupId; + + // Advanced hit, reference to artifactId. + private String artifactId; + + private String repositoryId = ""; + + private List versions = new ArrayList<>(); + + private String packaging; + + /** + * Plugin goal prefix (only if packaging is "maven-plugin") + */ + private String prefix; + + /** + * Plugin goals (only if packaging is "maven-plugin") + */ + private List goals; + + /** + * contains osgi metadata Bundle-Version if available + * + * @since 1.4-M1 + */ + private String bundleVersion; + + /** + * contains osgi metadata Bundle-SymbolicName if available + * + * @since 1.4-M1 + */ + private String bundleSymbolicName; + + /** + * contains osgi metadata Export-Package if available + * + * @since 1.4-M1 + */ + private String bundleExportPackage; + + /** + * contains osgi metadata Export-Service if available + * + * @since 1.4-M1 + */ + private String bundleExportService; + + /** + * contains osgi metadata Bundle-Description if available + * + * @since 1.4-M1 + */ + private String bundleDescription; + + /** + * contains osgi metadata Bundle-Name if available + * + * @since 1.4-M1 + */ + private String bundleName; + + /** + * contains osgi metadata Bundle-License if available + * + * @since 1.4-M1 + */ + private String bundleLicense; + + /** + * contains osgi metadata Bundle-DocURL if available + * + * @since 1.4-M1 + */ + private String bundleDocUrl; + + /** + * contains osgi metadata Import-Package if available + * + * @since 1.4-M1 + */ + private String bundleImportPackage; + + /** + * contains osgi metadata Require-Bundle if available + * + * @since 1.4-M1 + */ + private String bundleRequireBundle; + + private String classifier; + + /** + * file extension of the search result + * @since 1.4-M2 + */ + private String fileExtension; + + public String getContext() + { + return context; + } + + public void setContext( String context ) + { + this.context = context; + } + + public String getUrl() + { + return url; + } + + public void setUrl( String url ) + { + this.url = url; + } + + public String getUrlFilename() + { + return this.url.substring( this.url.lastIndexOf( '/' ) ); + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public List getVersions() + { + return versions; + } + + public void setVersions( List versions ) + { + this.versions = versions; + } + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + + public void addVersion( String version ) + { + versions.add( version ); + } + + public String getBundleVersion() + { + return bundleVersion; + } + + public void setBundleVersion( String bundleVersion ) + { + this.bundleVersion = bundleVersion; + } + + public String getBundleSymbolicName() + { + return bundleSymbolicName; + } + + public void setBundleSymbolicName( String bundleSymbolicName ) + { + this.bundleSymbolicName = bundleSymbolicName; + } + + public String getBundleExportPackage() + { + return bundleExportPackage; + } + + public void setBundleExportPackage( String bundleExportPackage ) + { + this.bundleExportPackage = bundleExportPackage; + } + + public String getBundleExportService() + { + return bundleExportService; + } + + public void setBundleExportService( String bundleExportService ) + { + this.bundleExportService = bundleExportService; + } + + public String getPrefix() + { + return prefix; + } + + public void setPrefix( String prefix ) + { + this.prefix = prefix; + } + + public List getGoals() + { + return goals; + } + + public void setGoals( List goals ) + { + this.goals = goals; + } + + public String getBundleDescription() + { + return bundleDescription; + } + + public void setBundleDescription( String bundleDescription ) + { + this.bundleDescription = bundleDescription; + } + + public String getBundleName() + { + return bundleName; + } + + public void setBundleName( String bundleName ) + { + this.bundleName = bundleName; + } + + public String getBundleLicense() + { + return bundleLicense; + } + + public void setBundleLicense( String bundleLicense ) + { + this.bundleLicense = bundleLicense; + } + + public String getBundleDocUrl() + { + return bundleDocUrl; + } + + public void setBundleDocUrl( String bundleDocUrl ) + { + this.bundleDocUrl = bundleDocUrl; + } + + public String getBundleImportPackage() + { + return bundleImportPackage; + } + + public void setBundleImportPackage( String bundleImportPackage ) + { + this.bundleImportPackage = bundleImportPackage; + } + + public String getBundleRequireBundle() + { + return bundleRequireBundle; + } + + public void setBundleRequireBundle( String bundleRequireBundle ) + { + this.bundleRequireBundle = bundleRequireBundle; + } + + public String getPackaging() + { + return packaging; + } + + public void setPackaging( String packaging ) + { + this.packaging = packaging; + } + + public String getType() + { + return getPackaging(); + } + + public String getClassifier() + { + return classifier; + } + + public void setClassifier( String classifier ) + { + this.classifier = classifier; + } + + public String getFileExtension() + { + return fileExtension; + } + + public void setFileExtension( String fileExtension ) + { + this.fileExtension = fileExtension; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "SearchResultHit" ); + sb.append( "{context='" ).append( context ).append( '\'' ); + sb.append( ", url='" ).append( url ).append( '\'' ); + sb.append( ", groupId='" ).append( groupId ).append( '\'' ); + sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); + sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' ); + sb.append( ", versions=" ).append( versions ); + sb.append( ", packaging='" ).append( packaging ).append( '\'' ); + sb.append( ", prefix='" ).append( prefix ).append( '\'' ); + sb.append( ", goals=" ).append( goals ); + sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); + sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); + sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); + sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' ); + sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); + sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' ); + sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' ); + sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); + sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); + sb.append( ", classifier='" ).append( classifier ).append( '\'' ); + sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + + SearchResultHit that = (SearchResultHit) o; + + if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null ) + { + return false; + } + if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null ) + { + return false; + } + if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null ) + { + return false; + } + if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null ) + { + return false; + } + + return true; + } + + @Override + public int hashCode() + { + int result = groupId != null ? groupId.hashCode() : 0; + result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 ); + result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 ); + result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 ); + return result; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java new file mode 100644 index 000000000..967ecc5ae --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java @@ -0,0 +1,87 @@ +package org.apache.archiva.indexer.search; + +/* + * 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. + */ + +/** + * SearchResultLimits - used to provide the search some limits on how the results are returned. + * This can provide paging for the result + */ +public class SearchResultLimits +{ + /** + * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES. + * USE WITH CAUTION!! + */ + public static final int ALL_PAGES = ( -1 ); + + private int pageSize = 30; + + private int selectedPage = 0; + + /** + * @param selectedPage page selected use -1 for all pages + */ + public SearchResultLimits( int selectedPage ) + { + this.selectedPage = selectedPage; + } + + /** + * @param pageSize number of groupId:artifact per page + * @param selectedPage page selected use -1 for all pages + * @since 1.4-M4 + */ + public SearchResultLimits( int pageSize, int selectedPage ) + { + this.pageSize = pageSize; + this.selectedPage = selectedPage; + } + + public int getPageSize() + { + return pageSize; + } + + /** + * Set page size for maximum # of hits to return per page. + * + * @param pageSize size of page by # of hits. + */ + public void setPageSize( int pageSize ) + { + this.pageSize = pageSize; + } + + public int getSelectedPage() + { + return selectedPage; + } + + public void setSelectedPage( int selectedPage ) + { + this.selectedPage = selectedPage; + } + + @Override + public String toString() + { + return "SearchResultLimits{" + "pageSize=" + pageSize + ", selectedPage=" + selectedPage + '}'; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java new file mode 100644 index 000000000..9dc650fdc --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java @@ -0,0 +1,148 @@ +package org.apache.archiva.indexer.search; + +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * SearchResults + * + */ +public class SearchResults +{ + private Map hits = new HashMap<>(); + + private int totalHits; + + private int totalHitsMapSize; + + private int returnedHitsCount; + + private SearchResultLimits limits; + + public SearchResults() + { + /* do nothing */ + } + + // for new RepositorySearch + public void addHit( String id, SearchResultHit hit ) + { + hits.put( id, hit ); + } + + /** + * Get the list of {@link SearchResultHit} objects. + * + * @return the list of {@link SearchResultHit} objects. + */ + public List getHits() + { + return new ArrayList<>( hits.values() ); + } + + /** + * see SearchUtil on how to generate the key + * + * @param key + * @return + */ + public SearchResultHit getSearchResultHit( String key ) + { + return hits.get( key ); + } + + public Map getHitsMap() + { + return hits; + } + + public boolean isEmpty() + { + return hits.isEmpty(); + } + + public SearchResultLimits getLimits() + { + return limits; + } + + public void setLimits( SearchResultLimits limits ) + { + this.limits = limits; + } + + public int getTotalHits() + { + return totalHits; + } + + public void setTotalHits( int totalHits ) + { + this.totalHits = totalHits; + } + + /** + * @return + * @since 1.4-M1 + */ + public int getReturnedHitsCount() + { + return returnedHitsCount; + } + + /** + * @param returnedHitsCount + * @since 1.4-M1 + */ + public void setReturnedHitsCount( int returnedHitsCount ) + { + this.returnedHitsCount = returnedHitsCount; + } + + /** + * @return + * @since 1.4-M1 + */ + public int getTotalHitsMapSize() + { + return totalHitsMapSize; + } + + /** + * @param totalHitsMapSize + * @since 1.4-M1 + */ + public void setTotalHitsMapSize( int totalHitsMapSize ) + { + this.totalHitsMapSize = totalHitsMapSize; + } + + @Override + public String toString() + { + return "SearchResults{" + "hits=" + hits + ", totalHits=" + totalHits + ", returnedHitsCount=" + + returnedHitsCount + ", limits=" + limits + '}'; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java new file mode 100644 index 000000000..0a0c922ee --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java @@ -0,0 +1,36 @@ +package org.apache.archiva.indexer.util; + +/* + * 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.commons.lang.StringUtils; + +/** + * SearchUtil - utility class for search. + */ +public class SearchUtil +{ + public static String getHitId( String groupId, String artifactId, String classifier, String packaging ) + { + return ( StringUtils.isBlank( groupId ) ? "" : StringUtils.trim( groupId ) ) + ":" // + + ( StringUtils.isBlank( artifactId ) ? "" : StringUtils.trim( artifactId ) ) + ":" // + + ( StringUtils.isBlank( classifier ) ? "" : StringUtils.trim( classifier ) ) + ":" // + + ( StringUtils.isBlank( packaging ) ? "" : StringUtils.trim( packaging ) ); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ContentNotFoundException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ContentNotFoundException.java new file mode 100644 index 000000000..7579debfe --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ContentNotFoundException.java @@ -0,0 +1,50 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * ContentNotFoundException is thrown in response for requests for content that is not the repository. + * + * + */ +public class ContentNotFoundException + extends RepositoryException +{ + + public ContentNotFoundException() + { + super(); + } + + public ContentNotFoundException( String message, Throwable cause ) + { + super( message, cause ); + } + + public ContentNotFoundException( String message ) + { + super( message ); + } + + public ContentNotFoundException( Throwable cause ) + { + super( cause ); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableManagedRepository.java new file mode 100644 index 000000000..4596201c8 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableManagedRepository.java @@ -0,0 +1,56 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * The editable part of a managed repository. + */ +public interface EditableManagedRepository extends EditableRepository, ManagedRepository +{ + /** + * If true, the repository blocks redeployments of artifacts with the same version. + * @param blocksRedeployment The flag for blocking redeployments. + */ + void setBlocksRedeployment(boolean blocksRedeployment); + + /** + * Sets the content + * @param content + */ + void setContent(ManagedRepositoryContent content); + + /** + * Adds an active release scheme. Release schemes may be combined. + * @param scheme the scheme to add. + */ + void addActiveReleaseScheme(ReleaseScheme scheme); + + /** + * Removes an active release scheme from the set. + * @param scheme the scheme to remove. + */ + void removeActiveReleaseScheme(ReleaseScheme scheme); + + /** + * Clears all active release schemes. + */ + void clearActiveReleaseSchemes(); + +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRemoteRepository.java new file mode 100644 index 000000000..f8a054f21 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRemoteRepository.java @@ -0,0 +1,82 @@ +package org.apache.archiva.repository; + +/* + * 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.time.Duration; +import java.util.Map; + +/** + * The editable part of a remote repository + */ +public interface EditableRemoteRepository extends EditableRepository, RemoteRepository +{ + + /** + * Sets the login credentials for login to the remote repository. + * @param credentials + */ + void setCredentials(RepositoryCredentials credentials); + + /** + * Sets the path relative to the root url of the repository that should be used to check + * the availability of the repository. + * + * @param path The path string. + */ + void setCheckPath(String path); + + /** + * Sets additional parameters to be used to access the remote repository. + * @param params A map of parameters, may not be null. + */ + void setExtraParameters(Map params); + + /** + * Adds an additional parameter. + * @param key The key of the parameter + * @param value The value of the parameter + */ + void addExtraParameter(String key, String value); + + /** + * Sets the extra headers, that are added to the requests to the remote repository. + */ + void setExtraHeaders(Map headers); + + /** + * Adds an extra header. + * @param header The header name + * @param value The header value + */ + void addExtraHeader(String header, String value); + + /** + * Sets the timeout for requests to the remote repository. + * + * @param duration The amount of time, after that the request is aborted. + */ + void setTimeout(Duration duration); + + /** + * Sets the content. + * @param content + */ + void setContent(RemoteRepositoryContent content); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java new file mode 100644 index 000000000..b27549211 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepository.java @@ -0,0 +1,124 @@ +package org.apache.archiva.repository; + +/* + * 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.net.URI; +import java.util.Locale; + +/** + * This is the editable part of a repository. + * Normally a repository should also implement this interface but it is not + * required. + * + * Capabilities and features are a integral part of the implementation and not + * provided here by the interface. + * Feature setting methods are provided by the features itself. + * + */ +public interface EditableRepository extends Repository +{ + + /** + * Returns the primary locale used for setting the default values for + * name and description. + * + * @return The locale used for name and description when they are not set + */ + Locale getPrimaryLocale(); + + /** + * Sets the name for the given locale + * + * @param locale the locale for which the name is set + * @param name The name value in the language that matches the locale + */ + void setName( Locale locale, String name); + + /** + * Sets the description for the given locale + * + * @param locale the locale for which the description is set + * @param description The description in the language that matches the locale. + */ + void setDescription(Locale locale, String description); + + /** + * Sets the location of the repository. May be a URI that is suitable for the + * repository implementation. Not all implementations will accept the same URI schemes. + * @param location the location URI + * @throws UnsupportedURIException if the URI scheme is not supported by the repository type. + */ + void setLocation(URI location) throws UnsupportedURIException; + + /** + * Sets the base uri for relative location uris. + * + * @param baseUri + */ + void setBaseUri(URI baseUri); + + /** + * Adds a failover location for the repository. + * + * @param location The location that should be used as failover. + * @throws UnsupportedURIException if the URI scheme is not supported by the repository type. + */ + void addFailoverLocation(URI location) throws UnsupportedURIException; + + /** + * Removes a failover location from the set. + * + * @param location the location uri to remove + */ + void removeFailoverLocation(URI location); + + /** + * Clears the failover location set. + */ + void clearFailoverLocations(); + + /** + * Sets the flag for scanning the repository. If true, the repository will be scanned. + * You have to set the scheduling times, if you set this to true. + * + * @param scanned if true, the repository is scanned regulary. + */ + void setScanned(boolean scanned); + + /** + * Sets the scheduling definition, that defines the times, when the regular repository + * jobs are started. The cronExpression must be a valid + * quartz cron definition. + * + * @See http://www.quartz-scheduler.org/api/2.2.1/org/quartz/CronExpression.html + * + * @param cronExpression the cron expression. + * @throws IllegalArgumentException if the cron expression is not valid. + */ + void setSchedulingDefinition(String cronExpression) throws IllegalArgumentException; + + /** + * Sets the layout string. + * @param layout + */ + void setLayout(String layout); + + +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/LayoutException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/LayoutException.java new file mode 100644 index 000000000..f106937e7 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/LayoutException.java @@ -0,0 +1,40 @@ +package org.apache.archiva.repository; + +/* + * 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.common.ArchivaException; + +/** + * LayoutException + * + * + */ +public class LayoutException extends ArchivaException +{ + public LayoutException( String message, Throwable cause ) + { + super( message, cause ); + } + + public LayoutException( String message ) + { + super( message ); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepository.java new file mode 100644 index 000000000..550a9ce86 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepository.java @@ -0,0 +1,52 @@ +package org.apache.archiva.repository; + +/* + * 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.indexer.ArchivaIndexingContext; + +import java.util.Set; + +/** + * Represents a managed repository, that is readable and writable. + */ +public interface ManagedRepository extends Repository { + + /** + * Returns the interface to access the contents of this repository. + * + * @return The repository content. + */ + ManagedRepositoryContent getContent(); + + /** + * Returns true, if repeated deployments of the same artifact with the same version throws exceptions. + * @return + */ + boolean blocksRedeployments(); + + /** + * Returns the release schemes that are active by this repository. E.g. for maven repositories + * this may either be a release repository, a snapshot repository or a combined repository. + * @return + */ + Set getActiveReleaseSchemes(); + +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java new file mode 100644 index 000000000..bf47b472d --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java @@ -0,0 +1,225 @@ +package org.apache.archiva.repository; + +/* + * 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.model.ArchivaArtifact; +import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.model.ProjectReference; +import org.apache.archiva.model.VersionedReference; + +import java.nio.file.Path; +import java.util.Set; + +/** + * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way, + * without the need for processing based on filesystem paths, or working with the database. + */ +public interface ManagedRepositoryContent extends RepositoryContent +{ + + + + /** + * Delete from the managed repository all files / directories associated with the + * provided version reference. + * + * @param reference the version reference to delete. + * @throws ContentNotFoundException + */ + void deleteVersion( VersionedReference reference ) + throws ContentNotFoundException; + + /** + * delete a specified artifact from the repository + * + * @param artifactReference + * @throws ContentNotFoundException + */ + void deleteArtifact( ArtifactReference artifactReference ) + throws ContentNotFoundException; + + /** + * @param groupId + * @throws ContentNotFoundException + * @since 1.4-M3 + */ + void deleteGroupId( String groupId ) + throws ContentNotFoundException; + + /** + * + * @param namespace groupId for maven + * @param projectId artifactId for maven + * @throws ContentNotFoundException + */ + void deleteProject( String namespace, String projectId ) + throws RepositoryException; + + /** + *

+ * Convenience method to get the repository id. + *

+ *

+ * Equivalent to calling .getRepository().getId() + *

+ * + * @return the repository id. + */ + String getId(); + + /** + *

+ * Gather up the list of related artifacts to the ArtifactReference provided. + * This typically inclues the pom files, and those things with + * classifiers (such as doc, source code, test libs, etc...) + *

+ *

+ * NOTE: Some layouts (such as maven 1 "legacy") are not compatible with this query. + *

+ * + * @param reference the reference to work off of. + * @return the set of ArtifactReferences for related artifacts. + * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository. + */ + Set getRelatedArtifacts( ArtifactReference reference ) + throws ContentNotFoundException; + + /** + *

+ * Convenience method to get the repository (on disk) root directory. + *

+ *

+ * Equivalent to calling .getRepository().getLocation() + *

+ * + * @return the repository (on disk) root directory. + */ + String getRepoRoot(); + + /** + * Get the repository configuration associated with this + * repository content. + * + * @return the repository that is associated with this repository content. + */ + ManagedRepository getRepository(); + + /** + * Given a specific {@link ProjectReference}, return the list of available versions for + * that project reference. + * + * @param reference the project reference to work off of. + * @return the list of versions found for that project reference. + * @throws ContentNotFoundException if the project reference does nto exist within the repository. + * @throws LayoutException + */ + Set getVersions( ProjectReference reference ) + throws ContentNotFoundException, LayoutException; + + /** + *

+ * Given a specific {@link VersionedReference}, return the list of available versions for that + * versioned reference. + *

+ *

+ * NOTE: This is really only useful when working with SNAPSHOTs. + *

+ * + * @param reference the versioned reference to work off of. + * @return the set of versions found. + * @throws ContentNotFoundException if the versioned reference does not exist within the repository. + */ + Set getVersions( VersionedReference reference ) + throws ContentNotFoundException; + + /** + * Determines if the artifact referenced exists in the repository. + * + * @param reference the artifact reference to check for. + * @return true if the artifact referenced exists. + */ + boolean hasContent( ArtifactReference reference ); + + /** + * Determines if the project referenced exists in the repository. + * + * @param reference the project reference to check for. + * @return true it the project referenced exists. + */ + boolean hasContent( ProjectReference reference ); + + /** + * Determines if the version reference exists in the repository. + * + * @param reference the version reference to check for. + * @return true if the version referenced exists. + */ + boolean hasContent( VersionedReference reference ); + + /** + * Set the repository configuration to associate with this + * repository content. + * + * @param repo the repository to associate with this repository content. + */ + void setRepository( org.apache.archiva.repository.ManagedRepository repo ); + + /** + * Given an {@link ArtifactReference}, return the file reference to the artifact. + * + * @param reference the artifact reference to use. + * @return the relative path to the artifact. + */ + Path toFile( ArtifactReference reference ); + + /** + * Given an {@link ArchivaArtifact}, return the file reference to the artifact. + * + * @param reference the archiva artifact to use. + * @return the relative path to the artifact. + */ + Path toFile( ArchivaArtifact reference ); + + /** + * Given a {@link ProjectReference}, return the path to the metadata for + * the project. + * + * @param reference the reference to use. + * @return the path to the metadata file, or null if no metadata is appropriate. + */ + String toMetadataPath( ProjectReference reference ); + + /** + * Given a {@link VersionedReference}, return the path to the metadata for + * the specific version of the project. + * + * @param reference the reference to use. + * @return the path to the metadata file, or null if no metadata is appropriate. + */ + String toMetadataPath( VersionedReference reference ); + + /** + * Given an {@link ArchivaArtifact}, return the relative path to the artifact. + * + * @param reference the archiva artifact to use. + * @return the relative path to the artifact. + */ + String toPath( ArchivaArtifact reference ); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ReleaseScheme.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ReleaseScheme.java new file mode 100644 index 000000000..0868d35b4 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ReleaseScheme.java @@ -0,0 +1,27 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * Repository release schemes that change the handling of artifacts + */ +public enum ReleaseScheme { + RELEASE,SNAPSHOT +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RemoteRepository.java new file mode 100644 index 000000000..5a7c1e8ed --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RemoteRepository.java @@ -0,0 +1,73 @@ +package org.apache.archiva.repository; + +/* + * 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.time.Duration; +import java.util.Map; + +/** + * This represents a repository that is not fully managed by archiva. Its some kind of proxy that + * forwards requests to the remote repository and is able to cache artifacts locally. + */ +public interface RemoteRepository extends Repository { + + /** + * Returns the interface to access the content of the repository. + * @return + */ + RemoteRepositoryContent getContent(); + + /** + * Returns the credentials used to login to the remote repository. + * @return the credentials, null if not set. + */ + RepositoryCredentials getLoginCredentials(); + + /** + * Returns the path relative to the root url of the repository that should be used + * to check the availability of the repository. + * @return The check path, null if not set. + */ + String getCheckPath(); + + + /** + * Returns additional parameters, that are used for accessing the remote repository. + * @return A map of key, value pairs. + */ + Map getExtraParameters(); + + + /** + * Returns extra headers that are added to the request to the remote repository. + * @return + */ + Map getExtraHeaders(); + + /** + * Returns the time duration, after that the request is aborted and a error is returned, if the remote repository + * does not respond. + * @return The timeout. + */ + Duration getTimeout(); + + +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RemoteRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RemoteRepositoryContent.java new file mode 100644 index 000000000..246e3343b --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RemoteRepositoryContent.java @@ -0,0 +1,82 @@ +package org.apache.archiva.repository; + +/* + * 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.model.ArtifactReference; +import org.apache.archiva.model.RepositoryURL; + +/** + * RemoteRepositoryContent interface for interacting with a remote repository in an abstract way, + * without the need for processing based on URLs, or working with the database. + * + * + */ +public interface RemoteRepositoryContent extends RepositoryContent +{ + /** + *

+ * Convenience method to get the repository id. + *

+ * + *

+ * Equivalent to calling .getRepository().getId() + *

+ * + * @return the repository id. + */ + String getId(); + + /** + * Get the repository configuration associated with this + * repository content. + * + * @return the repository that is associated with this repository content. + */ + RemoteRepository getRepository(); + + /** + *

+ * Convenience method to get the repository url. + *

+ * + *

+ * Equivalent to calling new RepositoryURL( this.getRepository().getUrl() ) + *

+ * + * @return the repository url. + */ + RepositoryURL getURL(); + + /** + * Set the repository configuration to associate with this + * repository content. + * + * @param repo the repository to associate with this repository content. + */ + void setRepository( RemoteRepository repo ); + + /** + * Given an ArtifactReference, return the url to the artifact. + * + * @param reference the artifact reference to use. + * @return the relative path to the artifact. + */ + RepositoryURL toURL( ArtifactReference reference ); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java new file mode 100644 index 000000000..1c101ee48 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java @@ -0,0 +1,169 @@ +package org.apache.archiva.repository; + +/* + * 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.indexer.ArchivaIndexingContext; +import org.apache.archiva.repository.features.RepositoryFeature; + +import java.net.URI; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +/** + * + * Base interface for repositories. + * + * Created by Martin Stockhammer on 21.09.17. + */ +public interface Repository { + + /** + * Return the identifier of the repository. Repository identifier should be unique at least + * for the same type. + * @return The identifier. + */ + String getId(); + + /** + * This is the display name of the repository. This string is presented in the user interface. + * + * @return The display name of the repository + */ + String getName(); + + /** + * Returns the name in the given locale. + * @param locale + * @return + */ + String getName(Locale locale); + + /** + * Returns a description of this repository. + * @return The description. + */ + String getDescription(); + + /** + * Returns the description for the given locale. + * @param locale + * @return + */ + String getDescription(Locale locale); + + /** + * This identifies the type of repository. Archiva does only support certain types of repositories. + * + * @return A unique identifier for the repository type. + */ + RepositoryType getType(); + + + /** + * Returns the location of this repository. For local repositories this might be a file URI, for + * remote repositories a http URL or some very repository specific schemes. + * Each repository has only one unique location. + * + * @return The repository location. + */ + URI getLocation(); + + /** + * This returns the absolute location uri of this repository. Some repository locations may be relative to + * the base repository directory or uri. This returns the absolute path of the repository. + * If the location is absolute already this method returns the same URI as getLocation(). + * + * @return the absolute uri of the location. + */ + URI getAbsoluteLocation(); + + /** + * A repository may allow additional locations that can be used, if the primary location is not available. + * @return + */ + Set getFailoverLocations(); + + /** + * True, if this repository is scanned regularly. + */ + boolean isScanned(); + + /** + * Returns the definition, when the repository jobs are executed. + * This must return a valid a cron string. + * + * @See http://www.quartz-scheduler.org/api/2.2.1/org/quartz/CronExpression.html + * + * @return + */ + String getSchedulingDefinition(); + + /** + * Returns true, if this repository has a index available + * @return + */ + boolean hasIndex(); + + /** + * Returns a layout definition. The returned string may be implementation specific and is not + * standardized. + * + * @return + */ + String getLayout(); + + + /** + * Returns the capabilities of the repository implementation. + * @return + */ + RepositoryCapabilities getCapabilities(); + + + /** + * Extension method that allows to provide different features that are not supported by all + * repository types. + * + * @param clazz The feature class that is requested + * @param This is the class of the feature + * @return The feature implementation for this repository instance, if it is supported + * @throws UnsupportedFeatureException if the feature is not supported by this repository type + */ + > RepositoryFeature getFeature(Class clazz) throws UnsupportedFeatureException; + + + /** + * Returns true, if the requested feature is supported by this repository. + * + * @param clazz The requested feature class + * @param The requested feature class + * @return True, if the feature is supported, otherwise false. + */ + > boolean supportsFeature(Class clazz); + + + /** + * Returns a indexing context. + * @return + * @throws UnsupportedOperationException + */ + ArchivaIndexingContext getIndexingContext(); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryCapabilities.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryCapabilities.java new file mode 100644 index 000000000..525d52130 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryCapabilities.java @@ -0,0 +1,99 @@ +package org.apache.archiva.repository; + +/* + * 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.Set; + +/** + * Describe the capabilities a repository implementation supports. + */ +public interface RepositoryCapabilities { + + /** + * Returns true, if this repository has a mechanism for indexes + * @return true, if this repository is indexable, otherwise false. + */ + default boolean isIndexable() { + return true; + } + + /** + * Returns true, if this repository type is storing its artifacts on the filesystem. + * @return true, if this is a file based repository, otherwise false. + */ + default boolean isFileBased() { + return true; + } + + /** + * Returns true, if this repository allows to block redeployments to prevent overriding + * released artifacts + * @return true, if this repo can block redeployments, otherwise false. + */ + default boolean canBlockRedeployments() { + return true; + } + + /** + * Returns true, if the artifacts can be scanned for metadata retrieval or maintenance tasks + * @return true, if this repository can be scanned regularily, otherwise false. + */ + default boolean isScannable() { + return true; + } + + /** + * Returns true, if this repository can use failover repository urls + * @return true, if there is a failover mechanism for repository access, otherwise false. + */ + default boolean allowsFailover() { + return false; + } + + /** + * Returns the release schemes this repository type can handle + */ + Set supportedReleaseSchemes(); + + /** + * Returns the layouts this repository type can provide + * @return The list of layouts supported by this repository. + */ + Set supportedLayouts(); + + /** + * Returns additional capabilities, that this repository type implements. + * @return A list of custom capabilities. + */ + Set customCapabilities(); + + /** + * Returns the supported features this repository type supports. This method returns + * string that corresponds to fully qualified class names. + * We use string representation to allow implementations provide their own feature + * implementations if necessary and to avoid class errors. + * + * @return The list of supported features as string values. + */ + Set supportedFeatures(); + + +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContent.java new file mode 100644 index 000000000..d959a8629 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContent.java @@ -0,0 +1,51 @@ +package org.apache.archiva.repository; + +/* + * 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.model.ArtifactReference; +import org.apache.archiva.model.VersionedReference; + + +/** + * Common aspects of content provider interfaces + */ +public interface RepositoryContent +{ + + + /** + * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path. + * + * @param path the path relative to the repository base dir for the artifact. + * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to + * a {@link ArtifactReference}) + * @throws LayoutException if there was a problem converting the path to an artifact. + */ + ArtifactReference toArtifactReference( String path ) + throws LayoutException; + + /** + * Given an {@link ArtifactReference}, return the relative path to the artifact. + * + * @param reference the artifact reference to use. + * @return the relative path to the artifact. + */ + String toPath( ArtifactReference reference ); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java new file mode 100644 index 000000000..65d54e605 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java @@ -0,0 +1,216 @@ +package org.apache.archiva.repository; + +/* + * 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.configuration.ArchivaConfiguration; +import org.apache.archiva.configuration.ConfigurationNames; +import org.apache.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.redback.components.registry.Registry; +import org.apache.archiva.redback.components.registry.RegistryListener; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import javax.inject.Inject; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * RepositoryContentRequest + */ +@Service( "repositoryContentFactory#default" ) +public class RepositoryContentFactory + implements RegistryListener +{ + /** + * + */ + @Inject + private ArchivaConfiguration archivaConfiguration; + + @Inject + private ApplicationContext applicationContext; + + @Inject + private List repositoryContentProviders; + + private final Map managedContentMap; + + private final Map remoteContentMap; + + + public RepositoryContentFactory( ) + { + managedContentMap = new ConcurrentHashMap( ); + remoteContentMap = new ConcurrentHashMap( ); + } + + /** + * Get the ManagedRepositoryContent object for the repository Id specified. + * + * @param repoId the repository id to fetch. + * @return the ManagedRepositoryContent object associated with the repository id. + * @throws RepositoryNotFoundException if the repository id does not exist within the configuration. + * @throws RepositoryException the repository content object cannot be loaded due to configuration issue. + */ + public ManagedRepositoryContent getManagedRepositoryContent( String repoId ) + throws RepositoryException + { + ManagedRepositoryContent repo = managedContentMap.get( repoId ); + + if ( repo != null ) + { + return repo; + } + else + { + throw new RepositoryNotFoundException( + "Unable to find managed repository configuration for id " + repoId ); + } + + } + + private RepositoryContentProvider getProvider(final String layout, final RepositoryType repoType) throws RepositoryException + { + return repositoryContentProviders.stream().filter(p->p.supports( repoType ) && p.supportsLayout( layout )). + findFirst().orElseThrow( ( ) -> new RepositoryException( "Could not find content provider for repository type "+repoType+" and layout "+layout ) ); + } + + public ManagedRepositoryContent getManagedRepositoryContent( org.apache.archiva.repository.ManagedRepository mRepo ) + throws RepositoryException + { + final String id = mRepo.getId(); + ManagedRepositoryContent content = managedContentMap.get( id ); + + if ( content != null && content.getRepository()==mRepo) + { + return content; + } + + RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) ); + content = contentProvider.createManagedContent( mRepo ); + if (content==null) { + throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() ); + } + ManagedRepositoryContent previousContent = managedContentMap.put( id, content ); + if (previousContent!=null) { + previousContent.setRepository( null ); + } + + return content; + } + + public RemoteRepositoryContent getRemoteRepositoryContent( String repoId ) + throws RepositoryException + { + RemoteRepositoryContent repo = remoteContentMap.get( repoId ); + + if ( repo != null ) + { + return repo; + } + else + { + throw new RepositoryNotFoundException( + "Unable to find remote repository configuration for id:" + repoId ); + } + + } + + public RemoteRepositoryContent getRemoteRepositoryContent( RemoteRepository mRepo ) + throws RepositoryException + { + final String id = mRepo.getId(); + RemoteRepositoryContent content = remoteContentMap.get( id ); + + if ( content != null && content.getRepository()==mRepo) + { + return content; + } + + RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) ); + content = contentProvider.createRemoteContent( mRepo ); + if (content==null) { + throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() ); + } + RemoteRepositoryContent previousContent = remoteContentMap.put( id, content ); + if (previousContent!=null) { + previousContent.setRepository( null ); + } + return content; + } + + + @Override + public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) + { + if ( ConfigurationNames.isManagedRepositories( propertyName ) || ConfigurationNames.isRemoteRepositories( + propertyName ) ) + { + initMaps( ); + } + } + + @Override + public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) + { + /* do nothing */ + } + + @PostConstruct + public void initialize( ) + { + archivaConfiguration.addChangeListener( this ); + } + + private void initMaps( ) + { + // olamy we use concurent so no need of synchronize + //synchronized ( managedContentMap ) + //{ + managedContentMap.clear( ); + //} + + //synchronized ( remoteContentMap ) + //{ + remoteContentMap.clear( ); + //} + } + + public ArchivaConfiguration getArchivaConfiguration( ) + { + return archivaConfiguration; + } + + public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) + { + this.archivaConfiguration = archivaConfiguration; + } + + public void setRepositoryContentProviders(List providers) { + this.repositoryContentProviders = providers; + } + + public List getRepositoryContentProviders() { + return repositoryContentProviders; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentProvider.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentProvider.java new file mode 100644 index 000000000..823444925 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentProvider.java @@ -0,0 +1,82 @@ +package org.apache.archiva.repository; + +/* + * 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.Set; + +/** + * A repository content provider creates repository content instances for specific repository types. + */ +public interface RepositoryContentProvider +{ + /** + * Returns true, if this content object supports the given layout otherwise, false. + * @param layout the layout string + * @return true, if layout is supported, otherwise false. + */ + boolean supportsLayout(String layout); + + /** + * Returns the repository types, this content object can be used for. + * + * @return all supported repository types. + */ + Set getSupportedRepositoryTypes(); + + + /** + * Returns true, if this content object supports the given repository type. + * + * @param type the type to check. + * @return true, if the type is supported, otherwise false. + */ + boolean supports(RepositoryType type); + + /** + * Creates a new instance of RemoteRepositoryContent. The returned instance should be initialized + * from the given repository data. + * + * @param repository the repository + * @return a repository content instance + * @throws RepositoryException if the layout is not supported, or a error occured during initialization + */ + RemoteRepositoryContent createRemoteContent(RemoteRepository repository) throws RepositoryException; + + /** + * Creates a new instance of ManagedRepositoryContent. + * + * @param repository the repository + * @return a new instance + * @throws RepositoryException if the layout is not supported, or a error occured during initialization + */ + ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException; + + /** + * Creates a generic content object. + * + * @param repository the repository + * @param clazz the content class + * @param the generic type of the content + * @param the generic type of the repository (must correspond to the content class) + * @return a new instance + * @throws RepositoryException if the clazz, or layout is not supported, or something went wrong during initialization + */ + T createContent(Class clazz, V repository) throws RepositoryException; +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryCredentials.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryCredentials.java new file mode 100644 index 000000000..2751bc05e --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryCredentials.java @@ -0,0 +1,31 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + + +/** + * Credentials used to login to a remote repository. + */ +public interface RepositoryCredentials { + + +} + + diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryException.java new file mode 100644 index 000000000..b9dca9553 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryException.java @@ -0,0 +1,51 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * RepositoryException + * + * + */ +public class RepositoryException + extends Exception +{ + + public RepositoryException() + { + super(); + } + + public RepositoryException( String message, Throwable cause ) + { + super( message, cause ); + } + + public RepositoryException( String message ) + { + super( message ); + } + + public RepositoryException( Throwable cause ) + { + super( cause ); + } + +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryNotFoundException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryNotFoundException.java new file mode 100644 index 000000000..ad4ad9b2f --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryNotFoundException.java @@ -0,0 +1,49 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * RepositoryNotFoundException + * + * + */ +public class RepositoryNotFoundException + extends RepositoryException +{ + + public RepositoryNotFoundException() + { + } + + public RepositoryNotFoundException( String message, Throwable cause ) + { + super( message, cause ); + } + + public RepositoryNotFoundException( String message ) + { + super( message ); + } + + public RepositoryNotFoundException( Throwable cause ) + { + super( cause ); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java new file mode 100644 index 000000000..a501514da --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java @@ -0,0 +1,139 @@ +package org.apache.archiva.repository; + +/* + * 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.configuration.ManagedRepositoryConfiguration; +import org.apache.archiva.configuration.RemoteRepositoryConfiguration; + +import java.util.Set; + +/** + * + * This interface must be implemented by the repository implementations. The repository provider knows all + * about the repositories and should be the only part that uses the repository specific classes and libraries + * (e.g. the maven libraries). + * + * Newly created instances should always be filled with default values that make sense. null values should + * be avoided. + * + * References like staging repositories must not be set. + * + * + */ +public interface RepositoryProvider +{ + + /** + * Returns the types of repositories this provider can handle. + * + * @return the set of supported repository types + */ + Set provides(); + + /** + * Creates a editable managed repository instance. The provider must not check the uniqueness of the + * id parameter and must not track the already created instances. Each call to this method will create + * a new instance. + * + * @param id the repository identifier + * @param name the repository name + * @return a new created managed repository instance + */ + EditableManagedRepository createManagedInstance(String id, String name); + + /** + * Creates a editable remote repository instance. The provider must not check the uniqueness of the + * id parameter and must not track the already created instances. Each call to this method will create + * a new instance. + * + * @param id the repository identifier + * @param name the repository name + * @return a new created remote repository instance + */ + EditableRemoteRepository createRemoteInstance(String id, String name); + + /** + * Creates a new managed repository instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param configuration the repository configuration that contains the repository data + * @return a new created managed repository instance + * @throws RepositoryException if some of the configuration values are not valid + */ + ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration) throws RepositoryException; + + /** + * Updates the given managed repository instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param repo the repository instance that should be updated + * @param configuration the repository configuration that contains the repository data + * @throws RepositoryException if some of the configuration values are not valid + */ + void updateManagedInstance( EditableManagedRepository repo, ManagedRepositoryConfiguration configuration) throws RepositoryException; + + /** + * Creates a new managed staging repository instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param baseConfiguration the repository configuration of the base repository that references the staging repository + * @return a new created managed staging repository instance + * @throws RepositoryException if some of the configuration values are not valid + */ + ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration) throws RepositoryException; + + /** + * Creates a new remote repository instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param configuration the repository configuration that contains the repository data + * @return a new created remote repository instance + * @throws RepositoryException if some of the configuration values are not valid + */ + RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration) throws RepositoryException; + + /** + * Updates the given remote repository instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param repo the repository instance that should be updated + * @param configuration the repository configuration that contains the repository data + * @throws RepositoryException if some of the configuration values are not valid + */ + void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration configuration) throws RepositoryException; + + /** + * Returns a configuration object from the given remote repository instance. + * + * @param remoteRepository the remote repository instance + * @return the repository configuration with all the data that is stored in the repository instance + * @throws RepositoryException if the data cannot be converted + */ + RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException; + + /** + * Returns a configuration object from the given managed repository instance. + * + * @param managedRepository the managed repository instance + * @return the repository configuration with all the data that is stored in the repository instance + * @throws RepositoryException if the data cannot be converted + */ + ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException; +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryType.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryType.java new file mode 100644 index 000000000..f60c65787 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryType.java @@ -0,0 +1,29 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + + +/** + * The repository types that are known to the system. + */ +public enum RepositoryType { + + MAVEN, NPM +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/StandardCapabilities.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/StandardCapabilities.java new file mode 100644 index 000000000..0a41c0497 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/StandardCapabilities.java @@ -0,0 +1,131 @@ +package org.apache.archiva.repository; + +/* + * 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.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * Capability implementation. + */ +public class StandardCapabilities implements RepositoryCapabilities +{ + private final Set supportedReleaseSchemes; + private final Set uSupportedReleaseSchemes; + private final Set supportedLayouts; + private final Set uSupportedLayouts; + private final Set customCapabilities; + private final Set uCustomCapabilities; + private final Set supportedFeatures; + private final Set uSupportedFeatures; + private final boolean indexable; + private final boolean fileBased; + private final boolean canBlockRedeployments; + private final boolean scannable; + private final boolean allowsFailover; + + + public StandardCapabilities( ReleaseScheme[] supportedReleaseSchemes, String[] supportedLayouts, + String[] customCapabilities, String[] supportedFeatures, + boolean indexable, boolean fileBased, + boolean canBlockRedeployments, boolean scannable, boolean allowsFailover ) + { + this.supportedReleaseSchemes = new HashSet(); + for (ReleaseScheme scheme : supportedReleaseSchemes) { + this.supportedReleaseSchemes.add(scheme); + } + this.uSupportedReleaseSchemes = Collections.unmodifiableSet( this.supportedReleaseSchemes); + this.supportedLayouts = new HashSet<>( ); + for (String layout : supportedLayouts) { + this.supportedLayouts.add(layout); + } + this.uSupportedLayouts = Collections.unmodifiableSet( this.supportedLayouts ); + this.customCapabilities = new HashSet<>( ); + for (String cap : customCapabilities) { + this.customCapabilities.add(cap); + } + this.uCustomCapabilities = Collections.unmodifiableSet( this.customCapabilities ); + this.supportedFeatures = new HashSet<>( ); + for (String feature : supportedFeatures) { + this.supportedFeatures.add(feature); + } + this.uSupportedFeatures = Collections.unmodifiableSet( this.supportedFeatures ); + this.indexable = indexable; + this.fileBased = fileBased; + this.canBlockRedeployments = canBlockRedeployments; + this.scannable = scannable; + this.allowsFailover = allowsFailover; + } + + @Override + public Set supportedReleaseSchemes( ) + { + return uSupportedReleaseSchemes; + } + + @Override + public Set supportedLayouts( ) + { + return uSupportedLayouts; + } + + @Override + public Set customCapabilities( ) + { + return uCustomCapabilities; + } + + @Override + public Set supportedFeatures( ) + { + return uSupportedFeatures; + } + + @Override + public boolean isIndexable( ) + { + return indexable; + } + + @Override + public boolean isFileBased( ) + { + return fileBased; + } + + @Override + public boolean canBlockRedeployments( ) + { + return canBlockRedeployments; + } + + @Override + public boolean isScannable( ) + { + return scannable; + } + + @Override + public boolean allowsFailover( ) + { + return allowsFailover; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedFeatureException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedFeatureException.java new file mode 100644 index 000000000..112f3075d --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedFeatureException.java @@ -0,0 +1,47 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * This exception is thrown if a given feature is not supported by the repository. + * This is a runtime exception. + * + */ +public class UnsupportedFeatureException extends RuntimeException { + + public UnsupportedFeatureException() { + } + + public UnsupportedFeatureException(String message) { + super(message); + } + + public UnsupportedFeatureException(String message, Throwable cause) { + super(message, cause); + } + + public UnsupportedFeatureException(Throwable cause) { + super(cause); + } + + public UnsupportedFeatureException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedRepositoryTypeException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedRepositoryTypeException.java new file mode 100644 index 000000000..9bfc02ecb --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedRepositoryTypeException.java @@ -0,0 +1,45 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * This is a fatal exception and should not happen. It is thrown if the implementation + * does not have certain classes to support this repository type. + */ +public class UnsupportedRepositoryTypeException extends RuntimeException { + + private static final String MESSAGE = "The repository type is not supported: "; + + public UnsupportedRepositoryTypeException(RepositoryType type) { + super(MESSAGE+type.name()); + } + + public UnsupportedRepositoryTypeException(RepositoryType type, Throwable cause) { + super(MESSAGE+type.name(), cause); + } + + public UnsupportedRepositoryTypeException(Throwable cause) { + super(cause); + } + + protected UnsupportedRepositoryTypeException(RepositoryType type, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(MESSAGE+type.name(), cause, enableSuppression, writableStackTrace); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedURIException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedURIException.java new file mode 100644 index 000000000..5f7f96f8a --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/UnsupportedURIException.java @@ -0,0 +1,51 @@ +package org.apache.archiva.repository; + +/* + * 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. + */ + +/** + * Exception is thrown, if the URI is syntactically correct, but is not + * supported by the underlying repository implementation + */ +public class UnsupportedURIException extends Exception +{ + public UnsupportedURIException( ) + { + } + + public UnsupportedURIException( String message ) + { + super( message ); + } + + public UnsupportedURIException( String message, Throwable cause ) + { + super( message, cause ); + } + + public UnsupportedURIException( Throwable cause ) + { + super( cause ); + } + + public UnsupportedURIException( String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace ) + { + super( message, cause, enableSuppression, writableStackTrace ); + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java new file mode 100644 index 000000000..a4df8a2a9 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java @@ -0,0 +1,41 @@ +package org.apache.archiva.repository.features; + +/* + * 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. + */ + + +/** + * Created by martin on 30.09.17. + */ +public interface RepositoryFeature> { + + default String getId() { + return this.getClass().getName(); + } + + default boolean isFeature(String featureId) { + return this.getClass().getName().equals(featureId); + } + + default > boolean isFeature(Class clazz) { + return this.getClass().equals(clazz); + } + + T get(); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-repository-api/src/main/resources/META-INF/spring-context.xml new file mode 100644 index 000000000..ce334de40 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/resources/META-INF/spring-context.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml index 8f2153439..2b03400ce 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml @@ -41,6 +41,10 @@ org.apache.archiva archiva-checksum
+ + org.apache.archiva + archiva-repository-api + org.apache.archiva archiva-configuration diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java index 0ff3cb1ad..ab1c3fa83 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java @@ -23,6 +23,7 @@ import com.cronutils.model.CronType; import com.cronutils.model.definition.CronDefinition; import com.cronutils.model.definition.CronDefinitionBuilder; import com.cronutils.parser.CronParser; +import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.repository.features.RepositoryFeature; import java.net.URI; @@ -237,4 +238,10 @@ public abstract class AbstractRepository implements EditableRepository protected > void addFeature(RepositoryFeature feature) { featureMap.put( (Class>) feature.getClass(), feature); } + + @Override + public ArchivaIndexingContext getIndexingContext() { + // TODO: Implement + return null; + } } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ContentNotFoundException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ContentNotFoundException.java deleted file mode 100644 index 7579debfe..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ContentNotFoundException.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * ContentNotFoundException is thrown in response for requests for content that is not the repository. - * - * - */ -public class ContentNotFoundException - extends RepositoryException -{ - - public ContentNotFoundException() - { - super(); - } - - public ContentNotFoundException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ContentNotFoundException( String message ) - { - super( message ); - } - - public ContentNotFoundException( Throwable cause ) - { - super( cause ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableManagedRepository.java deleted file mode 100644 index 4596201c8..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableManagedRepository.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * The editable part of a managed repository. - */ -public interface EditableManagedRepository extends EditableRepository, ManagedRepository -{ - /** - * If true, the repository blocks redeployments of artifacts with the same version. - * @param blocksRedeployment The flag for blocking redeployments. - */ - void setBlocksRedeployment(boolean blocksRedeployment); - - /** - * Sets the content - * @param content - */ - void setContent(ManagedRepositoryContent content); - - /** - * Adds an active release scheme. Release schemes may be combined. - * @param scheme the scheme to add. - */ - void addActiveReleaseScheme(ReleaseScheme scheme); - - /** - * Removes an active release scheme from the set. - * @param scheme the scheme to remove. - */ - void removeActiveReleaseScheme(ReleaseScheme scheme); - - /** - * Clears all active release schemes. - */ - void clearActiveReleaseSchemes(); - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableRemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableRemoteRepository.java deleted file mode 100644 index f8a054f21..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableRemoteRepository.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.time.Duration; -import java.util.Map; - -/** - * The editable part of a remote repository - */ -public interface EditableRemoteRepository extends EditableRepository, RemoteRepository -{ - - /** - * Sets the login credentials for login to the remote repository. - * @param credentials - */ - void setCredentials(RepositoryCredentials credentials); - - /** - * Sets the path relative to the root url of the repository that should be used to check - * the availability of the repository. - * - * @param path The path string. - */ - void setCheckPath(String path); - - /** - * Sets additional parameters to be used to access the remote repository. - * @param params A map of parameters, may not be null. - */ - void setExtraParameters(Map params); - - /** - * Adds an additional parameter. - * @param key The key of the parameter - * @param value The value of the parameter - */ - void addExtraParameter(String key, String value); - - /** - * Sets the extra headers, that are added to the requests to the remote repository. - */ - void setExtraHeaders(Map headers); - - /** - * Adds an extra header. - * @param header The header name - * @param value The header value - */ - void addExtraHeader(String header, String value); - - /** - * Sets the timeout for requests to the remote repository. - * - * @param duration The amount of time, after that the request is aborted. - */ - void setTimeout(Duration duration); - - /** - * Sets the content. - * @param content - */ - void setContent(RemoteRepositoryContent content); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableRepository.java deleted file mode 100644 index b27549211..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/EditableRepository.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.net.URI; -import java.util.Locale; - -/** - * This is the editable part of a repository. - * Normally a repository should also implement this interface but it is not - * required. - * - * Capabilities and features are a integral part of the implementation and not - * provided here by the interface. - * Feature setting methods are provided by the features itself. - * - */ -public interface EditableRepository extends Repository -{ - - /** - * Returns the primary locale used for setting the default values for - * name and description. - * - * @return The locale used for name and description when they are not set - */ - Locale getPrimaryLocale(); - - /** - * Sets the name for the given locale - * - * @param locale the locale for which the name is set - * @param name The name value in the language that matches the locale - */ - void setName( Locale locale, String name); - - /** - * Sets the description for the given locale - * - * @param locale the locale for which the description is set - * @param description The description in the language that matches the locale. - */ - void setDescription(Locale locale, String description); - - /** - * Sets the location of the repository. May be a URI that is suitable for the - * repository implementation. Not all implementations will accept the same URI schemes. - * @param location the location URI - * @throws UnsupportedURIException if the URI scheme is not supported by the repository type. - */ - void setLocation(URI location) throws UnsupportedURIException; - - /** - * Sets the base uri for relative location uris. - * - * @param baseUri - */ - void setBaseUri(URI baseUri); - - /** - * Adds a failover location for the repository. - * - * @param location The location that should be used as failover. - * @throws UnsupportedURIException if the URI scheme is not supported by the repository type. - */ - void addFailoverLocation(URI location) throws UnsupportedURIException; - - /** - * Removes a failover location from the set. - * - * @param location the location uri to remove - */ - void removeFailoverLocation(URI location); - - /** - * Clears the failover location set. - */ - void clearFailoverLocations(); - - /** - * Sets the flag for scanning the repository. If true, the repository will be scanned. - * You have to set the scheduling times, if you set this to true. - * - * @param scanned if true, the repository is scanned regulary. - */ - void setScanned(boolean scanned); - - /** - * Sets the scheduling definition, that defines the times, when the regular repository - * jobs are started. The cronExpression must be a valid - * quartz cron definition. - * - * @See http://www.quartz-scheduler.org/api/2.2.1/org/quartz/CronExpression.html - * - * @param cronExpression the cron expression. - * @throws IllegalArgumentException if the cron expression is not valid. - */ - void setSchedulingDefinition(String cronExpression) throws IllegalArgumentException; - - /** - * Sets the layout string. - * @param layout - */ - void setLayout(String layout); - - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepository.java deleted file mode 100644 index b4ab89d98..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepository.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.Set; - -/** - * Represents a managed repository, that is readable and writable. - */ -public interface ManagedRepository extends Repository { - - /** - * Returns the interface to access the contents of this repository. - * - * @return The repository content. - */ - ManagedRepositoryContent getContent(); - - /** - * Returns true, if repeated deployments of the same artifact with the same version throws exceptions. - * @return - */ - boolean blocksRedeployments(); - - /** - * Returns the release schemes that are active by this repository. E.g. for maven repositories - * this may either be a release repository, a snapshot repository or a combined repository. - * @return - */ - Set getActiveReleaseSchemes(); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java deleted file mode 100644 index 5baf32fdb..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.model.ArchivaArtifact; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.model.ProjectReference; -import org.apache.archiva.model.VersionedReference; -import org.apache.archiva.repository.layout.LayoutException; - -import java.nio.file.Path; -import java.util.Set; - -/** - * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way, - * without the need for processing based on filesystem paths, or working with the database. - */ -public interface ManagedRepositoryContent extends RepositoryContent -{ - - - - /** - * Delete from the managed repository all files / directories associated with the - * provided version reference. - * - * @param reference the version reference to delete. - * @throws ContentNotFoundException - */ - void deleteVersion( VersionedReference reference ) - throws ContentNotFoundException; - - /** - * delete a specified artifact from the repository - * - * @param artifactReference - * @throws ContentNotFoundException - */ - void deleteArtifact( ArtifactReference artifactReference ) - throws ContentNotFoundException; - - /** - * @param groupId - * @throws ContentNotFoundException - * @since 1.4-M3 - */ - void deleteGroupId( String groupId ) - throws ContentNotFoundException; - - /** - * - * @param namespace groupId for maven - * @param projectId artifactId for maven - * @throws ContentNotFoundException - */ - void deleteProject( String namespace, String projectId ) - throws RepositoryException; - - /** - *

- * Convenience method to get the repository id. - *

- *

- * Equivalent to calling .getRepository().getId() - *

- * - * @return the repository id. - */ - String getId(); - - /** - *

- * Gather up the list of related artifacts to the ArtifactReference provided. - * This typically inclues the pom files, and those things with - * classifiers (such as doc, source code, test libs, etc...) - *

- *

- * NOTE: Some layouts (such as maven 1 "legacy") are not compatible with this query. - *

- * - * @param reference the reference to work off of. - * @return the set of ArtifactReferences for related artifacts. - * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository. - */ - Set getRelatedArtifacts( ArtifactReference reference ) - throws ContentNotFoundException; - - /** - *

- * Convenience method to get the repository (on disk) root directory. - *

- *

- * Equivalent to calling .getRepository().getLocation() - *

- * - * @return the repository (on disk) root directory. - */ - String getRepoRoot(); - - /** - * Get the repository configuration associated with this - * repository content. - * - * @return the repository that is associated with this repository content. - */ - ManagedRepository getRepository(); - - /** - * Given a specific {@link ProjectReference}, return the list of available versions for - * that project reference. - * - * @param reference the project reference to work off of. - * @return the list of versions found for that project reference. - * @throws ContentNotFoundException if the project reference does nto exist within the repository. - * @throws LayoutException - */ - Set getVersions( ProjectReference reference ) - throws ContentNotFoundException, LayoutException; - - /** - *

- * Given a specific {@link VersionedReference}, return the list of available versions for that - * versioned reference. - *

- *

- * NOTE: This is really only useful when working with SNAPSHOTs. - *

- * - * @param reference the versioned reference to work off of. - * @return the set of versions found. - * @throws ContentNotFoundException if the versioned reference does not exist within the repository. - */ - Set getVersions( VersionedReference reference ) - throws ContentNotFoundException; - - /** - * Determines if the artifact referenced exists in the repository. - * - * @param reference the artifact reference to check for. - * @return true if the artifact referenced exists. - */ - boolean hasContent( ArtifactReference reference ); - - /** - * Determines if the project referenced exists in the repository. - * - * @param reference the project reference to check for. - * @return true it the project referenced exists. - */ - boolean hasContent( ProjectReference reference ); - - /** - * Determines if the version reference exists in the repository. - * - * @param reference the version reference to check for. - * @return true if the version referenced exists. - */ - boolean hasContent( VersionedReference reference ); - - /** - * Set the repository configuration to associate with this - * repository content. - * - * @param repo the repository to associate with this repository content. - */ - void setRepository( org.apache.archiva.repository.ManagedRepository repo ); - - /** - * Given an {@link ArtifactReference}, return the file reference to the artifact. - * - * @param reference the artifact reference to use. - * @return the relative path to the artifact. - */ - Path toFile( ArtifactReference reference ); - - /** - * Given an {@link ArchivaArtifact}, return the file reference to the artifact. - * - * @param reference the archiva artifact to use. - * @return the relative path to the artifact. - */ - Path toFile( ArchivaArtifact reference ); - - /** - * Given a {@link ProjectReference}, return the path to the metadata for - * the project. - * - * @param reference the reference to use. - * @return the path to the metadata file, or null if no metadata is appropriate. - */ - String toMetadataPath( ProjectReference reference ); - - /** - * Given a {@link VersionedReference}, return the path to the metadata for - * the specific version of the project. - * - * @param reference the reference to use. - * @return the path to the metadata file, or null if no metadata is appropriate. - */ - String toMetadataPath( VersionedReference reference ); - - /** - * Given an {@link ArchivaArtifact}, return the relative path to the artifact. - * - * @param reference the archiva artifact to use. - * @return the relative path to the artifact. - */ - String toPath( ArchivaArtifact reference ); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ReleaseScheme.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ReleaseScheme.java deleted file mode 100644 index 0868d35b4..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/ReleaseScheme.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * Repository release schemes that change the handling of artifacts - */ -public enum ReleaseScheme { - RELEASE,SNAPSHOT -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RemoteRepository.java deleted file mode 100644 index 5a7c1e8ed..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RemoteRepository.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.time.Duration; -import java.util.Map; - -/** - * This represents a repository that is not fully managed by archiva. Its some kind of proxy that - * forwards requests to the remote repository and is able to cache artifacts locally. - */ -public interface RemoteRepository extends Repository { - - /** - * Returns the interface to access the content of the repository. - * @return - */ - RemoteRepositoryContent getContent(); - - /** - * Returns the credentials used to login to the remote repository. - * @return the credentials, null if not set. - */ - RepositoryCredentials getLoginCredentials(); - - /** - * Returns the path relative to the root url of the repository that should be used - * to check the availability of the repository. - * @return The check path, null if not set. - */ - String getCheckPath(); - - - /** - * Returns additional parameters, that are used for accessing the remote repository. - * @return A map of key, value pairs. - */ - Map getExtraParameters(); - - - /** - * Returns extra headers that are added to the request to the remote repository. - * @return - */ - Map getExtraHeaders(); - - /** - * Returns the time duration, after that the request is aborted and a error is returned, if the remote repository - * does not respond. - * @return The timeout. - */ - Duration getTimeout(); - - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RemoteRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RemoteRepositoryContent.java deleted file mode 100644 index 7002d7ebe..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RemoteRepositoryContent.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.model.ArtifactReference; -import org.apache.archiva.model.RepositoryURL; -import org.apache.archiva.repository.layout.LayoutException; - -/** - * RemoteRepositoryContent interface for interacting with a remote repository in an abstract way, - * without the need for processing based on URLs, or working with the database. - * - * - */ -public interface RemoteRepositoryContent extends RepositoryContent -{ - /** - *

- * Convenience method to get the repository id. - *

- * - *

- * Equivalent to calling .getRepository().getId() - *

- * - * @return the repository id. - */ - String getId(); - - /** - * Get the repository configuration associated with this - * repository content. - * - * @return the repository that is associated with this repository content. - */ - RemoteRepository getRepository(); - - /** - *

- * Convenience method to get the repository url. - *

- * - *

- * Equivalent to calling new RepositoryURL( this.getRepository().getUrl() ) - *

- * - * @return the repository url. - */ - RepositoryURL getURL(); - - /** - * Set the repository configuration to associate with this - * repository content. - * - * @param repo the repository to associate with this repository content. - */ - void setRepository( RemoteRepository repo ); - - /** - * Given an ArtifactReference, return the url to the artifact. - * - * @param reference the artifact reference to use. - * @return the relative path to the artifact. - */ - RepositoryURL toURL( ArtifactReference reference ); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/Repository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/Repository.java deleted file mode 100644 index 68c00d621..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/Repository.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.features.RepositoryFeature; - -import java.net.URI; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -/** - * - * Base interface for repositories. - * - * Created by Martin Stockhammer on 21.09.17. - */ -public interface Repository { - - /** - * Return the identifier of the repository. Repository identifier should be unique at least - * for the same type. - * @return The identifier. - */ - String getId(); - - /** - * This is the display name of the repository. This string is presented in the user interface. - * - * @return The display name of the repository - */ - String getName(); - - /** - * Returns the name in the given locale. - * @param locale - * @return - */ - String getName(Locale locale); - - /** - * Returns a description of this repository. - * @return The description. - */ - String getDescription(); - - /** - * Returns the description for the given locale. - * @param locale - * @return - */ - String getDescription(Locale locale); - - /** - * This identifies the type of repository. Archiva does only support certain types of repositories. - * - * @return A unique identifier for the repository type. - */ - RepositoryType getType(); - - - /** - * Returns the location of this repository. For local repositories this might be a file URI, for - * remote repositories a http URL or some very repository specific schemes. - * Each repository has only one unique location. - * - * @return The repository location. - */ - URI getLocation(); - - /** - * This returns the absolute location uri of this repository. Some repository locations may be relative to - * the base repository directory or uri. This returns the absolute path of the repository. - * If the location is absolute already this method returns the same URI as getLocation(). - * - * @return the absolute uri of the location. - */ - URI getAbsoluteLocation(); - - /** - * A repository may allow additional locations that can be used, if the primary location is not available. - * @return - */ - Set getFailoverLocations(); - - /** - * True, if this repository is scanned regularly. - */ - boolean isScanned(); - - /** - * Returns the definition, when the repository jobs are executed. - * This must return a valid a cron string. - * - * @See http://www.quartz-scheduler.org/api/2.2.1/org/quartz/CronExpression.html - * - * @return - */ - String getSchedulingDefinition(); - - /** - * Returns true, if this repository has a index available - * @return - */ - boolean hasIndex(); - - /** - * Returns a layout definition. The returned string may be implementation specific and is not - * standardized. - * - * @return - */ - String getLayout(); - - - /** - * Returns the capabilities of the repository implementation. - * @return - */ - RepositoryCapabilities getCapabilities(); - - - /** - * Extension method that allows to provide different features that are not supported by all - * repository types. - * - * @param clazz The feature class that is requested - * @param This is the class of the feature - * @return The feature implementation for this repository instance, if it is supported - * @throws UnsupportedFeatureException if the feature is not supported by this repository type - */ - > RepositoryFeature getFeature(Class clazz) throws UnsupportedFeatureException; - - - /** - * Returns true, if the requested feature is supported by this repository. - * - * @param clazz The requested feature class - * @param The requested feature class - * @return True, if the feature is supported, otherwise false. - */ - > boolean supportsFeature(Class clazz); - - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryCapabilities.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryCapabilities.java deleted file mode 100644 index 525d52130..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryCapabilities.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.Set; - -/** - * Describe the capabilities a repository implementation supports. - */ -public interface RepositoryCapabilities { - - /** - * Returns true, if this repository has a mechanism for indexes - * @return true, if this repository is indexable, otherwise false. - */ - default boolean isIndexable() { - return true; - } - - /** - * Returns true, if this repository type is storing its artifacts on the filesystem. - * @return true, if this is a file based repository, otherwise false. - */ - default boolean isFileBased() { - return true; - } - - /** - * Returns true, if this repository allows to block redeployments to prevent overriding - * released artifacts - * @return true, if this repo can block redeployments, otherwise false. - */ - default boolean canBlockRedeployments() { - return true; - } - - /** - * Returns true, if the artifacts can be scanned for metadata retrieval or maintenance tasks - * @return true, if this repository can be scanned regularily, otherwise false. - */ - default boolean isScannable() { - return true; - } - - /** - * Returns true, if this repository can use failover repository urls - * @return true, if there is a failover mechanism for repository access, otherwise false. - */ - default boolean allowsFailover() { - return false; - } - - /** - * Returns the release schemes this repository type can handle - */ - Set supportedReleaseSchemes(); - - /** - * Returns the layouts this repository type can provide - * @return The list of layouts supported by this repository. - */ - Set supportedLayouts(); - - /** - * Returns additional capabilities, that this repository type implements. - * @return A list of custom capabilities. - */ - Set customCapabilities(); - - /** - * Returns the supported features this repository type supports. This method returns - * string that corresponds to fully qualified class names. - * We use string representation to allow implementations provide their own feature - * implementations if necessary and to avoid class errors. - * - * @return The list of supported features as string values. - */ - Set supportedFeatures(); - - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContent.java deleted file mode 100644 index 2ceedec10..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContent.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.model.ArtifactReference; -import org.apache.archiva.model.VersionedReference; -import org.apache.archiva.repository.layout.LayoutException; - - -/** - * Common aspects of content provider interfaces - */ -public interface RepositoryContent -{ - - - /** - * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path. - * - * @param path the path relative to the repository base dir for the artifact. - * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to - * a {@link ArtifactReference}) - * @throws LayoutException if there was a problem converting the path to an artifact. - */ - ArtifactReference toArtifactReference( String path ) - throws LayoutException; - - /** - * Given an {@link ArtifactReference}, return the relative path to the artifact. - * - * @param reference the artifact reference to use. - * @return the relative path to the artifact. - */ - String toPath( ArtifactReference reference ); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java deleted file mode 100644 index 65d54e605..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.configuration.ArchivaConfiguration; -import org.apache.archiva.configuration.ConfigurationNames; -import org.apache.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.archiva.configuration.RemoteRepositoryConfiguration; -import org.apache.archiva.redback.components.registry.Registry; -import org.apache.archiva.redback.components.registry.RegistryListener; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * RepositoryContentRequest - */ -@Service( "repositoryContentFactory#default" ) -public class RepositoryContentFactory - implements RegistryListener -{ - /** - * - */ - @Inject - private ArchivaConfiguration archivaConfiguration; - - @Inject - private ApplicationContext applicationContext; - - @Inject - private List repositoryContentProviders; - - private final Map managedContentMap; - - private final Map remoteContentMap; - - - public RepositoryContentFactory( ) - { - managedContentMap = new ConcurrentHashMap( ); - remoteContentMap = new ConcurrentHashMap( ); - } - - /** - * Get the ManagedRepositoryContent object for the repository Id specified. - * - * @param repoId the repository id to fetch. - * @return the ManagedRepositoryContent object associated with the repository id. - * @throws RepositoryNotFoundException if the repository id does not exist within the configuration. - * @throws RepositoryException the repository content object cannot be loaded due to configuration issue. - */ - public ManagedRepositoryContent getManagedRepositoryContent( String repoId ) - throws RepositoryException - { - ManagedRepositoryContent repo = managedContentMap.get( repoId ); - - if ( repo != null ) - { - return repo; - } - else - { - throw new RepositoryNotFoundException( - "Unable to find managed repository configuration for id " + repoId ); - } - - } - - private RepositoryContentProvider getProvider(final String layout, final RepositoryType repoType) throws RepositoryException - { - return repositoryContentProviders.stream().filter(p->p.supports( repoType ) && p.supportsLayout( layout )). - findFirst().orElseThrow( ( ) -> new RepositoryException( "Could not find content provider for repository type "+repoType+" and layout "+layout ) ); - } - - public ManagedRepositoryContent getManagedRepositoryContent( org.apache.archiva.repository.ManagedRepository mRepo ) - throws RepositoryException - { - final String id = mRepo.getId(); - ManagedRepositoryContent content = managedContentMap.get( id ); - - if ( content != null && content.getRepository()==mRepo) - { - return content; - } - - RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) ); - content = contentProvider.createManagedContent( mRepo ); - if (content==null) { - throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() ); - } - ManagedRepositoryContent previousContent = managedContentMap.put( id, content ); - if (previousContent!=null) { - previousContent.setRepository( null ); - } - - return content; - } - - public RemoteRepositoryContent getRemoteRepositoryContent( String repoId ) - throws RepositoryException - { - RemoteRepositoryContent repo = remoteContentMap.get( repoId ); - - if ( repo != null ) - { - return repo; - } - else - { - throw new RepositoryNotFoundException( - "Unable to find remote repository configuration for id:" + repoId ); - } - - } - - public RemoteRepositoryContent getRemoteRepositoryContent( RemoteRepository mRepo ) - throws RepositoryException - { - final String id = mRepo.getId(); - RemoteRepositoryContent content = remoteContentMap.get( id ); - - if ( content != null && content.getRepository()==mRepo) - { - return content; - } - - RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) ); - content = contentProvider.createRemoteContent( mRepo ); - if (content==null) { - throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() ); - } - RemoteRepositoryContent previousContent = remoteContentMap.put( id, content ); - if (previousContent!=null) { - previousContent.setRepository( null ); - } - return content; - } - - - @Override - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - if ( ConfigurationNames.isManagedRepositories( propertyName ) || ConfigurationNames.isRemoteRepositories( - propertyName ) ) - { - initMaps( ); - } - } - - @Override - public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - /* do nothing */ - } - - @PostConstruct - public void initialize( ) - { - archivaConfiguration.addChangeListener( this ); - } - - private void initMaps( ) - { - // olamy we use concurent so no need of synchronize - //synchronized ( managedContentMap ) - //{ - managedContentMap.clear( ); - //} - - //synchronized ( remoteContentMap ) - //{ - remoteContentMap.clear( ); - //} - } - - public ArchivaConfiguration getArchivaConfiguration( ) - { - return archivaConfiguration; - } - - public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) - { - this.archivaConfiguration = archivaConfiguration; - } - - public void setRepositoryContentProviders(List providers) { - this.repositoryContentProviders = providers; - } - - public List getRepositoryContentProviders() { - return repositoryContentProviders; - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContentProvider.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContentProvider.java deleted file mode 100644 index 823444925..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryContentProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.Set; - -/** - * A repository content provider creates repository content instances for specific repository types. - */ -public interface RepositoryContentProvider -{ - /** - * Returns true, if this content object supports the given layout otherwise, false. - * @param layout the layout string - * @return true, if layout is supported, otherwise false. - */ - boolean supportsLayout(String layout); - - /** - * Returns the repository types, this content object can be used for. - * - * @return all supported repository types. - */ - Set getSupportedRepositoryTypes(); - - - /** - * Returns true, if this content object supports the given repository type. - * - * @param type the type to check. - * @return true, if the type is supported, otherwise false. - */ - boolean supports(RepositoryType type); - - /** - * Creates a new instance of RemoteRepositoryContent. The returned instance should be initialized - * from the given repository data. - * - * @param repository the repository - * @return a repository content instance - * @throws RepositoryException if the layout is not supported, or a error occured during initialization - */ - RemoteRepositoryContent createRemoteContent(RemoteRepository repository) throws RepositoryException; - - /** - * Creates a new instance of ManagedRepositoryContent. - * - * @param repository the repository - * @return a new instance - * @throws RepositoryException if the layout is not supported, or a error occured during initialization - */ - ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException; - - /** - * Creates a generic content object. - * - * @param repository the repository - * @param clazz the content class - * @param the generic type of the content - * @param the generic type of the repository (must correspond to the content class) - * @return a new instance - * @throws RepositoryException if the clazz, or layout is not supported, or something went wrong during initialization - */ - T createContent(Class clazz, V repository) throws RepositoryException; -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryCredentials.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryCredentials.java deleted file mode 100644 index 2751bc05e..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryCredentials.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - - -/** - * Credentials used to login to a remote repository. - */ -public interface RepositoryCredentials { - - -} - - diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryException.java deleted file mode 100644 index b9dca9553..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryException.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * RepositoryException - * - * - */ -public class RepositoryException - extends Exception -{ - - public RepositoryException() - { - super(); - } - - public RepositoryException( String message, Throwable cause ) - { - super( message, cause ); - } - - public RepositoryException( String message ) - { - super( message ); - } - - public RepositoryException( Throwable cause ) - { - super( cause ); - } - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryNotFoundException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryNotFoundException.java deleted file mode 100644 index ad4ad9b2f..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryNotFoundException.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * RepositoryNotFoundException - * - * - */ -public class RepositoryNotFoundException - extends RepositoryException -{ - - public RepositoryNotFoundException() - { - } - - public RepositoryNotFoundException( String message, Throwable cause ) - { - super( message, cause ); - } - - public RepositoryNotFoundException( String message ) - { - super( message ); - } - - public RepositoryNotFoundException( Throwable cause ) - { - super( cause ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryProvider.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryProvider.java deleted file mode 100644 index a501514da..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryProvider.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.configuration.ManagedRepositoryConfiguration; -import org.apache.archiva.configuration.RemoteRepositoryConfiguration; - -import java.util.Set; - -/** - * - * This interface must be implemented by the repository implementations. The repository provider knows all - * about the repositories and should be the only part that uses the repository specific classes and libraries - * (e.g. the maven libraries). - * - * Newly created instances should always be filled with default values that make sense. null values should - * be avoided. - * - * References like staging repositories must not be set. - * - * - */ -public interface RepositoryProvider -{ - - /** - * Returns the types of repositories this provider can handle. - * - * @return the set of supported repository types - */ - Set provides(); - - /** - * Creates a editable managed repository instance. The provider must not check the uniqueness of the - * id parameter and must not track the already created instances. Each call to this method will create - * a new instance. - * - * @param id the repository identifier - * @param name the repository name - * @return a new created managed repository instance - */ - EditableManagedRepository createManagedInstance(String id, String name); - - /** - * Creates a editable remote repository instance. The provider must not check the uniqueness of the - * id parameter and must not track the already created instances. Each call to this method will create - * a new instance. - * - * @param id the repository identifier - * @param name the repository name - * @return a new created remote repository instance - */ - EditableRemoteRepository createRemoteInstance(String id, String name); - - /** - * Creates a new managed repository instance from the given configuration. All attributes are filled from the - * provided configuration object. - * - * @param configuration the repository configuration that contains the repository data - * @return a new created managed repository instance - * @throws RepositoryException if some of the configuration values are not valid - */ - ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration) throws RepositoryException; - - /** - * Updates the given managed repository instance from the given configuration. All attributes are filled from the - * provided configuration object. - * - * @param repo the repository instance that should be updated - * @param configuration the repository configuration that contains the repository data - * @throws RepositoryException if some of the configuration values are not valid - */ - void updateManagedInstance( EditableManagedRepository repo, ManagedRepositoryConfiguration configuration) throws RepositoryException; - - /** - * Creates a new managed staging repository instance from the given configuration. All attributes are filled from the - * provided configuration object. - * - * @param baseConfiguration the repository configuration of the base repository that references the staging repository - * @return a new created managed staging repository instance - * @throws RepositoryException if some of the configuration values are not valid - */ - ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration) throws RepositoryException; - - /** - * Creates a new remote repository instance from the given configuration. All attributes are filled from the - * provided configuration object. - * - * @param configuration the repository configuration that contains the repository data - * @return a new created remote repository instance - * @throws RepositoryException if some of the configuration values are not valid - */ - RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration) throws RepositoryException; - - /** - * Updates the given remote repository instance from the given configuration. All attributes are filled from the - * provided configuration object. - * - * @param repo the repository instance that should be updated - * @param configuration the repository configuration that contains the repository data - * @throws RepositoryException if some of the configuration values are not valid - */ - void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration configuration) throws RepositoryException; - - /** - * Returns a configuration object from the given remote repository instance. - * - * @param remoteRepository the remote repository instance - * @return the repository configuration with all the data that is stored in the repository instance - * @throws RepositoryException if the data cannot be converted - */ - RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException; - - /** - * Returns a configuration object from the given managed repository instance. - * - * @param managedRepository the managed repository instance - * @return the repository configuration with all the data that is stored in the repository instance - * @throws RepositoryException if the data cannot be converted - */ - ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException; -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryType.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryType.java deleted file mode 100644 index f60c65787..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryType.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - - -/** - * The repository types that are known to the system. - */ -public enum RepositoryType { - - MAVEN, NPM -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/StandardCapabilities.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/StandardCapabilities.java deleted file mode 100644 index 0a41c0497..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/StandardCapabilities.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * Capability implementation. - */ -public class StandardCapabilities implements RepositoryCapabilities -{ - private final Set supportedReleaseSchemes; - private final Set uSupportedReleaseSchemes; - private final Set supportedLayouts; - private final Set uSupportedLayouts; - private final Set customCapabilities; - private final Set uCustomCapabilities; - private final Set supportedFeatures; - private final Set uSupportedFeatures; - private final boolean indexable; - private final boolean fileBased; - private final boolean canBlockRedeployments; - private final boolean scannable; - private final boolean allowsFailover; - - - public StandardCapabilities( ReleaseScheme[] supportedReleaseSchemes, String[] supportedLayouts, - String[] customCapabilities, String[] supportedFeatures, - boolean indexable, boolean fileBased, - boolean canBlockRedeployments, boolean scannable, boolean allowsFailover ) - { - this.supportedReleaseSchemes = new HashSet(); - for (ReleaseScheme scheme : supportedReleaseSchemes) { - this.supportedReleaseSchemes.add(scheme); - } - this.uSupportedReleaseSchemes = Collections.unmodifiableSet( this.supportedReleaseSchemes); - this.supportedLayouts = new HashSet<>( ); - for (String layout : supportedLayouts) { - this.supportedLayouts.add(layout); - } - this.uSupportedLayouts = Collections.unmodifiableSet( this.supportedLayouts ); - this.customCapabilities = new HashSet<>( ); - for (String cap : customCapabilities) { - this.customCapabilities.add(cap); - } - this.uCustomCapabilities = Collections.unmodifiableSet( this.customCapabilities ); - this.supportedFeatures = new HashSet<>( ); - for (String feature : supportedFeatures) { - this.supportedFeatures.add(feature); - } - this.uSupportedFeatures = Collections.unmodifiableSet( this.supportedFeatures ); - this.indexable = indexable; - this.fileBased = fileBased; - this.canBlockRedeployments = canBlockRedeployments; - this.scannable = scannable; - this.allowsFailover = allowsFailover; - } - - @Override - public Set supportedReleaseSchemes( ) - { - return uSupportedReleaseSchemes; - } - - @Override - public Set supportedLayouts( ) - { - return uSupportedLayouts; - } - - @Override - public Set customCapabilities( ) - { - return uCustomCapabilities; - } - - @Override - public Set supportedFeatures( ) - { - return uSupportedFeatures; - } - - @Override - public boolean isIndexable( ) - { - return indexable; - } - - @Override - public boolean isFileBased( ) - { - return fileBased; - } - - @Override - public boolean canBlockRedeployments( ) - { - return canBlockRedeployments; - } - - @Override - public boolean isScannable( ) - { - return scannable; - } - - @Override - public boolean allowsFailover( ) - { - return allowsFailover; - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/UnsupportedFeatureException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/UnsupportedFeatureException.java deleted file mode 100644 index 112f3075d..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/UnsupportedFeatureException.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * This exception is thrown if a given feature is not supported by the repository. - * This is a runtime exception. - * - */ -public class UnsupportedFeatureException extends RuntimeException { - - public UnsupportedFeatureException() { - } - - public UnsupportedFeatureException(String message) { - super(message); - } - - public UnsupportedFeatureException(String message, Throwable cause) { - super(message, cause); - } - - public UnsupportedFeatureException(Throwable cause) { - super(cause); - } - - public UnsupportedFeatureException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/UnsupportedURIException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/UnsupportedURIException.java deleted file mode 100644 index 5f7f96f8a..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/UnsupportedURIException.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.archiva.repository; - -/* - * 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. - */ - -/** - * Exception is thrown, if the URI is syntactically correct, but is not - * supported by the underlying repository implementation - */ -public class UnsupportedURIException extends Exception -{ - public UnsupportedURIException( ) - { - } - - public UnsupportedURIException( String message ) - { - super( message ); - } - - public UnsupportedURIException( String message, Throwable cause ) - { - super( message, cause ); - } - - public UnsupportedURIException( Throwable cause ) - { - super( cause ); - } - - public UnsupportedURIException( String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace ) - { - super( message, cause, enableSuppression, writableStackTrace ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/PathParser.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/PathParser.java index 5dc960913..ddbcb6d59 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/PathParser.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/PathParser.java @@ -20,7 +20,7 @@ package org.apache.archiva.repository.content; */ import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; /** * PathParser interface. diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java deleted file mode 100644 index a4df8a2a9..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/features/RepositoryFeature.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.archiva.repository.features; - -/* - * 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. - */ - - -/** - * Created by martin on 30.09.17. - */ -public interface RepositoryFeature> { - - default String getId() { - return this.getClass().getName(); - } - - default boolean isFeature(String featureId) { - return this.getClass().getName().equals(featureId); - } - - default > boolean isFeature(Class clazz) { - return this.getClass().equals(clazz); - } - - T get(); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/layout/LayoutException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/layout/LayoutException.java deleted file mode 100644 index 6e3a77996..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/layout/LayoutException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.archiva.repository.layout; - -/* - * 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.common.ArchivaException; - -/** - * LayoutException - * - * - */ -public class LayoutException extends ArchivaException -{ - public LayoutException( String message, Throwable cause ) - { - super( message, cause ); - } - - public LayoutException( String message ) - { - super( message ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/MetadataTools.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/MetadataTools.java index 8706759a9..062169273 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/MetadataTools.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/MetadataTools.java @@ -36,7 +36,7 @@ import org.apache.archiva.redback.components.registry.RegistryListener; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RemoteRepositoryContent; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.xml.XMLException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; diff --git a/archiva-modules/archiva-base/pom.xml b/archiva-modules/archiva-base/pom.xml index d77129d62..5c3d64f6b 100644 --- a/archiva-modules/archiva-base/pom.xml +++ b/archiva-modules/archiva-base/pom.xml @@ -39,7 +39,7 @@ archiva-checksum archiva-plexus-bridge archiva-policies - archiva-indexer-api + archiva-repository-api archiva-indexer archiva-consumers archiva-repository-layer diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java index 96376736e..519ac4877 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java @@ -26,7 +26,7 @@ import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentFactory; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.springframework.stereotype.Service; import javax.inject.Inject; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 6598b0771..c42380e23 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -65,7 +65,7 @@ import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.content.maven2.RepositoryRequest; import org.apache.archiva.repository.events.AuditListener; import org.apache.archiva.repository.features.IndexCreationFeature; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.metadata.MetadataTools; import org.apache.archiva.repository.metadata.RepositoryMetadataException; import org.apache.archiva.repository.metadata.RepositoryMetadataMerge; diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index 359c7ebc1..4678950b7 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -47,7 +47,7 @@ import org.apache.archiva.proxy.common.WagonFactory; import org.apache.archiva.proxy.model.RepositoryProxyConnectors; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.xml.XMLException; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/AbstractDefaultRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/AbstractDefaultRepositoryContent.java index a15b5d76c..ae8a92281 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/AbstractDefaultRepositoryContent.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/AbstractDefaultRepositoryContent.java @@ -20,7 +20,6 @@ package org.apache.archiva.repository.content.maven2; */ import org.apache.archiva.common.utils.VersionUtil; -import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider; import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator; @@ -30,13 +29,11 @@ import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.RepositoryContent; import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.PostConstruct; -import javax.inject.Inject; import java.util.List; /** diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/DefaultPathParser.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/DefaultPathParser.java index c0bcaaf54..d28a8284b 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/DefaultPathParser.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/DefaultPathParser.java @@ -27,7 +27,7 @@ import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMapp import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java index 847dd7a6b..d5f55fc6e 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java @@ -28,9 +28,9 @@ import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.ContentNotFoundException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.layout.LayoutException; import org.apache.commons.lang.StringUtils; import java.io.IOException; @@ -245,8 +245,8 @@ public class ManagedDefaultRepositoryContent * information. * * @return the Set of available versions, based on the project reference. - * @throws org.apache.archiva.repository.layout.LayoutException - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException + * @throws LayoutException */ @Override public Set getVersions( ProjectReference reference ) @@ -395,7 +395,7 @@ public class ManagedDefaultRepositoryContent * Convert a path to an artifact reference. * * @param path the path to convert. (relative or full location path) - * @throws org.apache.archiva.repository.layout.LayoutException if the path cannot be converted to an artifact reference. + * @throws LayoutException if the path cannot be converted to an artifact reference. */ @Override public ArtifactReference toArtifactReference( String path ) @@ -440,7 +440,7 @@ public class ManagedDefaultRepositoryContent * @return the ArtifactReference to the first artifact located within the versioned reference. or null if * no artifact was found within the versioned reference. * @throws java.io.IOException if the versioned reference is invalid (example: doesn't exist, or isn't a directory) - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ private ArtifactReference getFirstArtifact( VersionedReference reference ) throws LayoutException, IOException diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java index b9c2238fa..17426d8b9 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java @@ -22,11 +22,9 @@ package org.apache.archiva.repository.content.maven2; import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.RepositoryURL; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepositoryContent; -import org.apache.archiva.repository.layout.LayoutException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; import java.util.List; @@ -80,7 +78,7 @@ public class RemoteDefaultRepositoryContent * Convert a path to an artifact reference. * * @param path the path to convert. (relative or full url path) - * @throws org.apache.archiva.repository.layout.LayoutException if the path cannot be converted to an artifact reference. + * @throws LayoutException if the path cannot be converted to an artifact reference. */ @Override public ArtifactReference toArtifactReference( String path ) diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RepositoryRequest.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RepositoryRequest.java index a1fc5bd62..fa7ec895b 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RepositoryRequest.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RepositoryRequest.java @@ -20,9 +20,9 @@ package org.apache.archiva.repository.content.maven2; */ import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.repository.metadata.MetadataTools; import org.apache.commons.lang.StringUtils; @@ -45,7 +45,7 @@ public class RepositoryRequest * * @param requestedPath the relative path to the content. * @return the ArtifactReference for the requestedPath. - * @throws org.apache.archiva.repository.layout.LayoutException if the request path is not layout valid. + * @throws LayoutException if the request path is not layout valid. */ public ArtifactReference toArtifactReference( String requestedPath ) throws LayoutException @@ -236,7 +236,7 @@ public class RepositoryRequest * @param requestedPath the incoming requested path. * @param repository the repository to adjust to. * @return the adjusted (to native) path. - * @throws org.apache.archiva.repository.layout.LayoutException if the path cannot be parsed. + * @throws LayoutException if the path cannot be parsed. */ public String toNativePath( String requestedPath, ManagedRepositoryContent repository ) throws LayoutException diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java index 0967e225f..c3b85ccf1 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java @@ -21,7 +21,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.AbstractRepositoryLayerTestCase; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.commons.lang.StringUtils; import org.junit.Test; @@ -82,7 +82,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException * */ @Test @@ -103,7 +103,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException * */ @Test @@ -124,7 +124,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase * Test the ejb-client type spec. * Type specs are not a 1 to 1 map to the extension. * This tests that effect. - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ /* TODO: Re-enabled in the future. public void testGoodFooEjbClient() @@ -145,7 +145,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException * */ @Test @@ -252,7 +252,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase /** * Test the classifier, and java-source type spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException * */ @Test @@ -272,7 +272,7 @@ public abstract class AbstractDefaultRepositoryContentTestCase /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException * */ @Test diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java index 41e62faa3..98bfac076 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java @@ -27,9 +27,8 @@ import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.EditableManagedRepository; -import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.junit.Before; import org.junit.Test; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java index 0a1c03acf..4af23f6fd 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java @@ -23,11 +23,10 @@ import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.content.maven2.RemoteDefaultRepositoryContent; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.junit.Before; import javax.inject.Inject; -import javax.inject.Named; import java.util.List; /** diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/DefaultPathParserTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/DefaultPathParserTest.java index 74b2c0df8..f46dfa2d0 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/DefaultPathParserTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/DefaultPathParserTest.java @@ -20,8 +20,8 @@ package org.apache.archiva.repository.content.maven2; */ import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.lang.StringUtils; import org.junit.Test; @@ -152,7 +152,7 @@ public class DefaultPathParserTest * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testGoodButOddVersionSpecGanymedSsh2() @@ -172,7 +172,7 @@ public class DefaultPathParserTest * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testGoodButOddVersionSpecJavaxComm() @@ -192,7 +192,7 @@ public class DefaultPathParserTest * Test the ejb-client type spec. * Type specs are not a 1 to 1 map to the extension. * This tests that effect. - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ /* TODO: Re-enabled in the future. public void testGoodFooEjbClient() @@ -213,7 +213,7 @@ public class DefaultPathParserTest * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testGoodButOddVersionSpecJavaxPersistence() @@ -333,7 +333,7 @@ public class DefaultPathParserTest /** * Test the classifier, and java-source type spec. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testGoodFooLibSources() @@ -352,7 +352,7 @@ public class DefaultPathParserTest /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testGoodSnapshotMavenTest() @@ -372,7 +372,7 @@ public class DefaultPathParserTest /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testGoodLongSnapshotMavenTest() @@ -401,7 +401,7 @@ public class DefaultPathParserTest /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. * - * @throws org.apache.archiva.repository.layout.LayoutException + * @throws LayoutException */ @Test public void testClassifiedSnapshotMavenTest() diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java index 928482b18..f918c1873 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java @@ -24,7 +24,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentProvider; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.lang.StringUtils; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java index 650f49fff..7bbf4cb6f 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java @@ -19,7 +19,6 @@ package org.apache.archiva.repository.metadata; * under the License. */ -import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.metadata.repository.storage.maven2.conf.MockConfiguration; @@ -33,7 +32,7 @@ import org.apache.archiva.repository.AbstractRepositoryLayerTestCase; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.RepositoryContentProvider; -import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; diff --git a/pom.xml b/pom.xml index 8b981b620..2469fd366 100644 --- a/pom.xml +++ b/pom.xml @@ -287,11 +287,6 @@ test-repository ${project.version}
- - org.apache.archiva - archiva-indexer-api - ${project.version} - org.apache.archiva archiva-indexer @@ -437,6 +432,11 @@ archiva-repository-layer ${project.version} + + org.apache.archiva + archiva-repository-api + ${project.version} + org.apache.archiva archiva-repository-scanner