Projects
openEuler:24.03:SP1:Everything
maven-resolver
_service:tar_scm:add-support-for-blocked-reposi...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:add-support-for-blocked-repository.patch of Package maven-resolver
From 514cec19743c4f441f0137cd6d035422a046e6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= <hboutemy@apache.org> Date: Sun, 7 Mar 2021 08:48:37 +0100 Subject: [PATCH] [MRESOLVER-166] add support for blocked repository/mirror --- .../aether/repository/RemoteRepository.java | 40 ++++++++++++++++++- .../repository/DefaultMirrorSelector.java | 21 ++++++++-- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java index fd5c480..52fc894 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java @@ -59,6 +59,8 @@ public final class RemoteRepository private final boolean repositoryManager; + private boolean blocked; + RemoteRepository( Builder builder ) { if ( builder.prototype != null ) @@ -76,6 +78,7 @@ public final class RemoteRepository repositoryManager = ( builder.delta & Builder.REPOMAN ) != 0 ? builder.repositoryManager : builder.prototype.repositoryManager; + blocked = ( builder.delta & Builder.BLOCKED ) != 0 ? builder.blocked : builder.prototype.blocked; mirroredRepositories = ( builder.delta & Builder.MIRRORED ) != 0 ? copy( builder.mirroredRepositories ) : builder.prototype.mirroredRepositories; @@ -90,7 +93,8 @@ public final class RemoteRepository proxy = builder.proxy; authentication = builder.authentication; repositoryManager = builder.repositoryManager; - mirroredRepositories = copy( builder.mirroredRepositories ); + blocked = builder.blocked; + mirroredRepositories = copy( builder.mirroredRepositories ); } Matcher m = URL_PATTERN.matcher( url ); @@ -207,6 +211,16 @@ public final class RemoteRepository return repositoryManager; } + /** + * Indicates whether this repository is blocked against any download request. + * + * @return {@code true} if this repository is blocked against any download request, {@code false} otherwise. + */ + public boolean isBlocked() + { + return blocked; + } + @Override public String toString() { @@ -235,6 +249,11 @@ public final class RemoteRepository { buffer.append( ", managed" ); } + if ( isBlocked() ) + { + buffer.append( ", blocked" ); + + } buffer.append( ")" ); return buffer.toString(); } @@ -294,7 +313,7 @@ public final class RemoteRepository private static final RepositoryPolicy DEFAULT_POLICY = new RepositoryPolicy(); static final int ID = 0x0001, TYPE = 0x0002, URL = 0x0004, RELEASES = 0x0008, SNAPSHOTS = 0x0010, - PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100; + PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100, BLOCKED = 0x0200; int delta; @@ -318,6 +337,8 @@ public final class RemoteRepository boolean repositoryManager; + boolean blocked; + /** * Creates a new repository builder. * @@ -574,6 +595,21 @@ public final class RemoteRepository return this; } + /** + * Marks the repository as blocked or not. + * + * @param blocked {@code true} if the repository should not be allowed to get any request. + * @return This builder for chaining, never {@code null}. + */ + public Builder setBlocked( boolean blocked ) + { + this.blocked = blocked; + if ( prototype != null ) + { + delta( BLOCKED, this.blocked, prototype.isBlocked() ); + } + return this; + } } } diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java index c123b47..f493708 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java @@ -39,6 +39,13 @@ public final class DefaultMirrorSelector private final List<MirrorDef> mirrors = new ArrayList<MirrorDef>(); + @Deprecated + public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager, + String mirrorOfIds, String mirrorOfTypes ) + { + return add( id, url, type, repositoryManager, false, mirrorOfIds, mirrorOfTypes ); + } + /** * Adds the specified mirror to this selector. * @@ -46,6 +53,7 @@ public final class DefaultMirrorSelector * @param url The URL of the mirror, must not be {@code null}. * @param type The content type of the mirror, must not be {@code null}. * @param repositoryManager A flag whether the mirror is a repository manager or a simple server. + * @param blocked A flag whether the mirror blocks any download request. * @param mirrorOfIds The identifier(s) of remote repositories to mirror, must not be {@code null}. Multiple * identifiers can be separated by comma and additionally the wildcards "*" and "external:*" can be used * to match all (external) repositories, prefixing a repo id with an exclamation mark allows to express @@ -55,10 +63,10 @@ public final class DefaultMirrorSelector * wildcard "*" and the "!" negation syntax are supported. For example "*,!p2". * @return This selector for chaining, never {@code null}. */ - public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager, + public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager, boolean blocked, String mirrorOfIds, String mirrorOfTypes ) { - mirrors.add( new MirrorDef( id, url, type, repositoryManager, mirrorOfIds, mirrorOfTypes ) ); + mirrors.add( new MirrorDef( id, url, type, repositoryManager, blocked, mirrorOfIds, mirrorOfTypes ) ); return this; } @@ -77,6 +85,8 @@ public final class DefaultMirrorSelector builder.setRepositoryManager( mirror.repositoryManager ); + builder.setBlocked( mirror.blocked ); + if ( mirror.type != null && mirror.type.length() > 0 ) { builder.setContentType( mirror.type ); @@ -253,17 +263,20 @@ public final class DefaultMirrorSelector final boolean repositoryManager; + final boolean blocked; + final String mirrorOfIds; final String mirrorOfTypes; - MirrorDef( String id, String url, String type, boolean repositoryManager, String mirrorOfIds, - String mirrorOfTypes ) + MirrorDef( String id, String url, String type, boolean repositoryManager, boolean blocked, String mirrorOfIds, + String mirrorOfTypes ) { this.id = id; this.url = url; this.type = type; this.repositoryManager = repositoryManager; + this.blocked = blocked; this.mirrorOfIds = mirrorOfIds; this.mirrorOfTypes = mirrorOfTypes; } -- 2.23.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2