diff --git c/api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java w/api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java index e130710..366d00e 100644 --- c/api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java +++ w/api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java @@ -834,7 +834,19 @@ public interface SakaiProxy { * *
This setting controls the display of the profile status section. * - * @return true or false. + * @return true or false. */ public boolean isProfileStatusEnabled(); + + /** + * Is the profile2.import.images flag set in sakai.properties? + * If not set, defaults to false + * + *
If enabled then at startup profile 2 will attempt to download any profile URLs set + * and upload them as profile images. + *
+ * + * @return true or false + */ + public boolean isProfileImageImportEnabled(); } diff --git c/api/src/java/org/sakaiproject/profile2/util/ProfileConstants.java w/api/src/java/org/sakaiproject/profile2/util/ProfileConstants.java index 2e3d398..c9868c8 100644 --- c/api/src/java/org/sakaiproject/profile2/util/ProfileConstants.java +++ w/api/src/java/org/sakaiproject/profile2/util/ProfileConstants.java @@ -211,6 +211,7 @@ public class ProfileConstants { public static final boolean SAKAI_PROP_PROFILE2_IMPORT_ENABLED = false; //profile2.import public static final boolean SAKAI_PROP_PROFILE2_PROFILE_FIELDS_ENABLED = true; //profile2.profile.fields.enabled public static final boolean SAKAI_PROP_PROFILE2_PROFILE_STATUS_ENABLED = true; //profile2.profile.status.enabled + public static final boolean SAKAI_PROP_PROFILE2_IMPORT_IMAGES_ENABLED = false; // profile2.import.images @@ -398,6 +399,7 @@ public class ProfileConstants { */ public static final String GOOGLE_REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"; public static final String GOOGLE_DOCS_SCOPE = "https://docs.google.com/feeds/"; + } diff --git c/impl/src/java/org/sakaiproject/profile2/conversion/ProfileConverter.java w/impl/src/java/org/sakaiproject/profile2/conversion/ProfileConverter.java index 580fcad..79d8f84 100644 --- c/impl/src/java/org/sakaiproject/profile2/conversion/ProfileConverter.java +++ w/impl/src/java/org/sakaiproject/profile2/conversion/ProfileConverter.java @@ -2,6 +2,11 @@ package org.sakaiproject.profile2.conversion; import java.io.FileNotFoundException; import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -13,12 +18,10 @@ import lombok.Getter; import lombok.Setter; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.log4j.Logger; import org.sakaiproject.api.common.edu.person.SakaiPerson; import org.sakaiproject.authz.api.SecurityAdvisor; import org.sakaiproject.authz.api.SecurityService; -import org.sakaiproject.authz.api.SecurityAdvisor.SecurityAdvice; import org.sakaiproject.profile2.dao.ProfileDao; import org.sakaiproject.profile2.exception.ProfileNotDefinedException; import org.sakaiproject.profile2.hbm.model.ProfileImageExternal; @@ -84,10 +87,6 @@ public class ProfileConverter { for(IteratorThe CSV file may contain any of the following headings, in any order:
diff --git c/impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java w/impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java
index 18e7f10..cb63533 100644
--- c/impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java
+++ w/impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java
@@ -377,6 +377,15 @@ public class ProfileLogicImpl implements ProfileLogic {
converter.convertProfileImages();
}
+ // Should we import profile image URLs to be uploaded profile images?
+ if (sakaiProxy.isProfileImageImportEnabled()) {
+ if (sakaiProxy.getProfilePictureType() != ProfileConstants.PICTURE_SETTING_UPLOAD) {
+ log.warn("I'm set to import images but profile2.picture.type=upload is not set. Not importing.");
+ } else {
+ converter.importProfileImages();
+ }
+ }
+
//do we need to import profiles?
if(sakaiProxy.isProfileImportEnabled()) {
diff --git c/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java w/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java
index 5751301..ee2054d 100644
--- c/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java
+++ w/impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java
@@ -980,6 +980,15 @@ public class SakaiProxyImpl implements SakaiProxy {
return serverConfigurationService.getBoolean("profile2.convert", ProfileConstants.SAKAI_PROP_PROFILE2_CONVERSION_ENABLED);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isProfileImageImportEnabled() {
+ return serverConfigurationService.getBoolean("profile2.import.images", ProfileConstants.SAKAI_PROP_PROFILE2_IMPORT_IMAGES_ENABLED);
+ }
+
+
/**
* {@inheritDoc}
*/
diff --git c/pom.xml w/pom.xml
index df175ba..56832ee 100644
--- c/pom.xml
+++ w/pom.xml
@@ -326,7 +326,7 @@