[ 
https://issues.apache.org/jira/browse/MRESOLVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17607378#comment-17607378
 ] 

ASF GitHub Bot commented on MRESOLVER-274:
------------------------------------------

cstamas commented on code in PR #197:
URL: https://github.com/apache/maven-resolver/pull/197#discussion_r975752655


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/filter/RemoteRepositoryFilterSourceSupport.java:
##########
@@ -0,0 +1,160 @@
+package org.eclipse.aether.internal.impl.filter;
+
+/*
+ * 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.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilter;
+import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource;
+import org.eclipse.aether.util.ConfigUtils;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Remote repository filter source filtering on G coordinate. It is backed by 
a file that lists all allowed groupIds
+ * and groupId not present in this file is filtered out. The file can be 
authored manually (groupId per line) or
+ * by this filter by "record" function. When "recording", this filter will not 
filter out anything, but will instead
+ * populate the file will all groupIds it was requested about.
+ *
+ * @since TBD
+ */
+public abstract class RemoteRepositoryFilterSourceSupport
+        implements RemoteRepositoryFilterSource
+{
+    private static final String CONFIG_PROP_PREFIX = 
"aether.remoteRepositoryFilter.";
+
+    private static final String CONF_NAME_ENABLED = "enabled";
+
+    private static final String CONF_NAME_INSTANCE = "instance";
+
+    private final String id;
+
+    private final String description;
+
+    protected RemoteRepositoryFilterSourceSupport( String id, String 
description )
+    {
+        this.id = requireNonNull( id );
+        this.description = requireNonNull( description );
+    }
+
+    @Override
+    public String getId()
+    {
+        return id;
+    }
+
+    @Override
+    public String getDescription()
+    {
+        return description;
+    }
+
+    @Override
+    public RemoteRepositoryFilter getRemoteRepositoryFilter( 
RepositorySystemSession session )
+    {
+        boolean enabled = ConfigUtils.getBoolean( session, false, 
configPropKey( CONF_NAME_ENABLED ) );
+        if ( !enabled )
+        {
+            return null;
+        }
+        return (RemoteRepositoryFilter) session.getData().computeIfAbsent( 
configPropKey( CONF_NAME_INSTANCE ), () ->
+        {
+            try
+            {
+                return doGetRemoteRepositoryFilter( session );
+            }
+            catch ( IOException e )
+            {
+                throw new UncheckedIOException( e );
+            }
+        } );
+    }
+
+    /**
+     * Implementing classes in this method must return non-null implementation 
of filter (as enabled was checked

Review Comment:
   This is untrue, implementation STILL MAY decide to return null, manager will 
handle it.





> Introduce Remote Repository Filter feature
> ------------------------------------------
>
>                 Key: MRESOLVER-274
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-274
>             Project: Maven Resolver
>          Issue Type: Improvement
>          Components: Resolver
>            Reporter: Tamás Cservenák
>            Assignee: Tamás Cservenák
>            Priority: Major
>             Fix For: resolver-next
>
>
> The feature, as it's name says should be able to "filter" RemoteRepositories 
> by some criteria ("known bad GAVs", "allowed groupId", etc).
> In short, this feature allows following filtering: "should be Artifact 
> available from RemoteRepository?" and is able to employ several combination 
> (via consensus, or later possibly other strategies) of several "filter 
> sources" that are extensible (via adding new components).
> Filter is used in two places:
>  * in connector, preventing remote artifact to be fetched from remote 
> repository (100% reliable)
>  * in resolution, preventing locally *cached* artifact to be resolved 
> (reliable as much as your local repository is "clean", ie. if you used Simple 
> LRM on it, it does not track remote origins will fail to filter, while 
> EnhancedLRM does track it and will work as expected).
> By default this feature is "dormant" (resolver behaves exactly same as before 
> without it). This is intended as "low level" feature that later can be built 
> upon, and implement some more user friendly solutions like MNG-6763. Hence, 
> this issue and resolver code changes are NOT meant to completely implement 
> MNG-6763, but more like to provide needed (lower level) functionalities to 
> make it possible.
> Examples:
>  * provide a list of groupIds (this is done by demo)
>  * use prefixes file (example central 
> [https://repo.maven.apache.org/maven2/.meta/prefixes.txt] or ASF releases 
> [https://repository.apache.org/content/repositories/releases/.meta/prefixes.txt)]
>  * maybe package up an artifact holding list of "known" bad artifacts and 
> consume that (and enforce it)
>  * etc...



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to