From 84f43536d5474f2077cf3b9a07b13b21ad853c3b Mon Sep 17 00:00:00 2001 From: James Moger Date: Tue, 15 Apr 2014 09:27:43 -0400 Subject: [PATCH] Removed obsolete Gravatar profile code --- releases.moxie | 1 + .../com/gitblit/models/GravatarProfile.java | 83 ------------------- .../java/com/gitblit/utils/ActivityUtils.java | 46 ---------- .../java/com/gitblit/tests/ActivityTest.java | 32 ------- 4 files changed, 1 insertion(+), 161 deletions(-) delete mode 100644 src/main/java/com/gitblit/models/GravatarProfile.java delete mode 100644 src/test/java/com/gitblit/tests/ActivityTest.java diff --git a/releases.moxie b/releases.moxie index 4749cce4..15d333d4 100644 --- a/releases.moxie +++ b/releases.moxie @@ -59,6 +59,7 @@ r22: { - Tim Ryan - Decebal Suiu - Eric Myrhe + - Kevin Walter settings: - { name: 'realm.ldap.bindpattern', defaultValue: ' ' } - { name: 'tickets.closeOnPushCommitMessageRegex', defaultValue: '(?:fixes|closes)[\\s-]+#?(\\d+)' } diff --git a/src/main/java/com/gitblit/models/GravatarProfile.java b/src/main/java/com/gitblit/models/GravatarProfile.java deleted file mode 100644 index ec1aeea3..00000000 --- a/src/main/java/com/gitblit/models/GravatarProfile.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2011 gitblit.com. - * - * Licensed 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 com.gitblit.models; - -import java.io.Serializable; -import java.util.List; - -/** - * Represents a Gravatar profile. - * - * @author James Moger - * - */ -public class GravatarProfile implements Serializable { - - private static final long serialVersionUID = 1L; - - public String id; - public String hash; - public String requestHash; - public String displayName; - public String preferredUsername; - public String currentLocation; - public String aboutMe; - - public String profileUrl; - public String thumbnailUrl; - public List photos; -// public Map profileBackground; -// public Map name; - - public List phoneNumbers; - public List emails; - public List ims; - public List accounts; - public List urls; - - public static class ProfileObject implements Serializable { - - private static final long serialVersionUID = 1L; - - public String title; - public String type; - public String value; - public boolean primary; - - @Override - public String toString() { - return value; - } - } - - public static class Account implements Serializable { - - private static final long serialVersionUID = 1L; - - public String domain; - public String display; - public String url; - public String username; - public String userid; - public boolean verified; - public String shortname; - - @Override - public String toString() { - return display; - } - } -} diff --git a/src/main/java/com/gitblit/utils/ActivityUtils.java b/src/main/java/com/gitblit/utils/ActivityUtils.java index 3a54d33f..ba5599a1 100644 --- a/src/main/java/com/gitblit/utils/ActivityUtils.java +++ b/src/main/java/com/gitblit/utils/ActivityUtils.java @@ -15,9 +15,6 @@ */ package com.gitblit.utils; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.Type; import java.text.DateFormat; import java.text.MessageFormat; import java.text.SimpleDateFormat; @@ -38,11 +35,9 @@ import com.gitblit.IStoredSettings; import com.gitblit.Keys; import com.gitblit.manager.IRepositoryManager; import com.gitblit.models.Activity; -import com.gitblit.models.GravatarProfile; import com.gitblit.models.RefModel; import com.gitblit.models.RepositoryCommit; import com.gitblit.models.RepositoryModel; -import com.google.gson.reflect.TypeToken; /** * Utility class for building activity information from repositories. @@ -161,19 +156,6 @@ public class ActivityUtils { return recentActivity; } - /** - * Returns the Gravatar profile, if available, for the specified email - * address. - * - * @param emailaddress - * @return a Gravatar Profile - * @throws IOException - */ - public static GravatarProfile getGravatarProfileFromAddress(String emailaddress) - throws IOException { - return getGravatarProfile(StringUtils.getMD5(emailaddress.toLowerCase())); - } - /** * Creates a Gravatar thumbnail url from the specified email address. * @@ -211,32 +193,4 @@ public class ActivityUtils { "https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=mm", emailHash, width); return url; } - - /** - * Returns the Gravatar profile, if available, for the specified hashcode. - * address. - * - * @param hash - * the hash of the email address - * @return a Gravatar Profile - * @throws IOException - */ - public static GravatarProfile getGravatarProfile(String hash) throws IOException { - String url = MessageFormat.format("https://www.gravatar.com/{0}.json", hash); - // Gravatar has a complex json structure - Type profileType = new TypeToken>>() { - }.getType(); - Map> profiles = null; - try { - profiles = JsonUtils.retrieveJson(url, profileType); - } catch (FileNotFoundException e) { - } - if (profiles == null || profiles.size() == 0) { - return null; - } - // due to the complex json structure we need to pull out the profile - // from a list 2 levels deep - GravatarProfile profile = profiles.values().iterator().next().get(0); - return profile; - } } diff --git a/src/test/java/com/gitblit/tests/ActivityTest.java b/src/test/java/com/gitblit/tests/ActivityTest.java deleted file mode 100644 index b7382b87..00000000 --- a/src/test/java/com/gitblit/tests/ActivityTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2011 gitblit.com. - * - * Licensed 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 com.gitblit.tests; - -import java.io.IOException; - -import org.junit.Test; - -import com.gitblit.models.GravatarProfile; -import com.gitblit.utils.ActivityUtils; - -public class ActivityTest extends GitblitUnitTest { - - @Test - public void testGravatarProfile() throws IOException { - GravatarProfile profile = ActivityUtils.getGravatarProfile("beau@dentedreality.com.au"); - assertEquals("beau", profile.preferredUsername); - } -} \ No newline at end of file -- 2.39.5