elharo commented on code in PR #97:
URL: 
https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1962763705


##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -83,9 +116,22 @@ public boolean canGenerateReport() throws 
MavenReportException {
     }
 
     @Override
-    public void executeReport(Locale locale) {
-        ProjectTeamRenderer r =
-                new ProjectTeamRenderer(getSink(), project.getModel(), 
getI18N(locale), locale, showAvatarImages);
+    public void executeReport(Locale locale) throws MavenReportException {
+        AvatarsProvider avatarsProvider = 
avatarsProviders.get(avatarProviderName);
+        if (avatarsProvider == null) {
+            throw new MavenReportException("No AvatarsProvider found for name 
" + avatarProviderName);

Review Comment:
   Would it make sense to instead simply not show avatars in the report? 



##########
src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+package org.apache.maven.report.projectinfo.avatars;
+
+import javax.inject.Named;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Provider for user avatar from gravatar.com
+ * <p>
+ * <a href="https://docs.gravatar.com/api/avatars/images/";>Gravatar API</a>
+ */
+@Named("gravatar")
+class GravatarProvider implements AvatarsProvider {
+
+    private static final String AVATAR_SIZE = "s=60";
+
+    private static final String AVATAR_DIRECTORY = "avatars";
+
+    private String baseUrl = "https://www.gravatar.com/avatar/";;
+
+    private Path outputDirectory;
+
+    @Override
+    public void setBaseUrl(String baseUrl) {
+        this.baseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
+    }
+
+    @Override
+    public void setOutputDirectory(File outputDirectory) {
+        this.outputDirectory = outputDirectory.toPath();
+    }
+
+    public String getExternalAvatarUrl(String email) {
+
+        if (email == null || email.isEmpty()) {
+            return getSpacerGravatarUrl();
+        }
+
+        email = email.trim().toLowerCase(Locale.ROOT);
+        MessageDigest md;

Review Comment:
   This can move into the try block, I think. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to