Author: taylor Date: Fri Jul 26 00:10:06 2013 New Revision: 1507158 URL: http://svn.apache.org/r1507158 Log: JS2-874: checkpoint #1 in refactoring of Jetspeed-API to use Java Collections Generics
Modified: portals/jetspeed-2/applications/j2-admin/trunk/pom.xml portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java Modified: portals/jetspeed-2/applications/j2-admin/trunk/pom.xml URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/pom.xml?rev=1507158&r1=1507157&r2=1507158&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/pom.xml (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/pom.xml Fri Jul 26 00:10:06 2013 @@ -406,8 +406,8 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> <debug>true</debug> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java?rev=1507158&r1=1507157&r2=1507158&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java Fri Jul 26 00:10:06 2013 @@ -16,26 +16,6 @@ */ package org.apache.jetspeed.portlets.registration; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; - -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; -import javax.portlet.PortletConfig; -import javax.portlet.PortletException; -import javax.portlet.PortletRequest; -import javax.portlet.PortletResponse; -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; - import org.apache.jetspeed.CommonPortletServices; import org.apache.jetspeed.PortalReservedParameters; import org.apache.jetspeed.administration.AdministrationEmailException; @@ -53,6 +33,11 @@ import org.apache.portals.bridges.veloci import org.apache.portals.gems.util.ValidationHelper; import org.apache.velocity.context.Context; +import javax.portlet.*; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.*; + /** * This portlet allows a logged on user to change its password. * @@ -142,7 +127,7 @@ public class ForgottenPasswordPortlet ex templateName = "forgottenPasswdEmail.vm"; } - ArrayList roots = new ArrayList(1); + List<String> roots = new ArrayList<String>(1); roots.add(templateLocation); try @@ -160,18 +145,15 @@ public class ForgottenPasswordPortlet ex private boolean isValidGUID(String guid) { - Map map = admin.getNewLoginInfo(guid); - - if (map != null) { return true; } - return false; + return (admin.getNewLoginInfo(guid) != null); } private boolean updatePasswordFromGUID(String guid) { - Map map = admin.getNewLoginInfo(guid); + Map<String,String> map = admin.getNewLoginInfo(guid); - String userName = (String) map.get("user.name"); - String newPassword = (String) map.get("password"); + String userName = map.get("user.name"); + String newPassword = map.get("password"); // Here's where a break should be. The following code should be put into the RETURN portlet try @@ -241,7 +223,7 @@ public class ForgottenPasswordPortlet ex public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { - List errors = new LinkedList(); + List<String> errors = new LinkedList<String>(); String email = request.getParameter(RP_EMAIL_ADDRESS); Locale locale = request.getLocale(); @@ -364,9 +346,9 @@ public class ForgottenPasswordPortlet ex return admin.getPortalURL(request, response, this.redirectPath); } - protected List makeMessage(String msg) + protected List<String> makeMessage(String msg) { - List errors = new LinkedList(); + List<String> errors = new LinkedList<String>(); errors.add(msg); return errors; } Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java?rev=1507158&r1=1507157&r2=1507158&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java Fri Jul 26 00:10:06 2013 @@ -16,31 +16,6 @@ */ package org.apache.jetspeed.portlets.registration; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; -import javax.portlet.PortletConfig; -import javax.portlet.PortletException; -import javax.portlet.PortletMode; -import javax.portlet.PortletPreferences; -import javax.portlet.PortletRequest; -import javax.portlet.PortletResponse; -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; -import javax.portlet.WindowState; - import org.apache.jetspeed.CommonPortletServices; import org.apache.jetspeed.JetspeedActions; import org.apache.jetspeed.PortalReservedParameters; @@ -59,6 +34,11 @@ import org.apache.portals.bridges.veloci import org.apache.portals.gems.util.ValidationHelper; import org.apache.velocity.context.Context; +import javax.portlet.*; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.*; + /** * This portlet allows a logged on user to change its password. * @@ -146,13 +126,13 @@ public class UserRegistrationPortlet ext private String returnUrlPath; /** roles */ - private List roles; + private List<String> roles; /** groups */ - private List groups; + private List<String> groups; /** profile rules */ - private Map rules; + private Map<String,String> rules; /** will force the passwords to be generated instead of picked by the user */ private boolean optionForceGeneratedPasswords = false; @@ -185,9 +165,9 @@ public class UserRegistrationPortlet ext this.groups = getInitParameterList(config, IP_GROUPS); // rules (name,value pairs) - List names = getInitParameterList(config, IP_RULES_NAMES); - List values = getInitParameterList(config, IP_RULES_VALUES); - rules = new HashMap(); + List<String> names = getInitParameterList(config, IP_RULES_NAMES); + List<String> values = getInitParameterList(config, IP_RULES_VALUES); + rules = new HashMap<String, String>(); for (int ix = 0; ix < ((names.size() < values.size()) ? names.size() : values.size()); ix++) { @@ -206,7 +186,7 @@ public class UserRegistrationPortlet ext templateName = "userRegistrationEmail.vm"; } - ArrayList roots = new ArrayList(1); + List<String> roots = new ArrayList<String>(1); roots.add(templateLocation); try @@ -323,9 +303,9 @@ public class UserRegistrationPortlet ext private static final Integer IS_BDATE = new Integer(5); - protected List getListOfNonSpecialFormKeys() + protected List<String> getListOfNonSpecialFormKeys() { - List l = new ArrayList(); + List<String> list = new ArrayList<String>(); for (int i = 0; i < formKeys.length; i++) { String key = (String) formKeys[i][0]; @@ -344,10 +324,10 @@ public class UserRegistrationPortlet ext } else { // but DO add this - l.add(key); + list.add(key); } } - return l; + return list; } protected Map getOptionalMap() @@ -509,11 +489,11 @@ public class UserRegistrationPortlet ext public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { - List errors = new LinkedList(); + List<String> errors = new LinkedList<String>(); - Map userAttributes = new HashMap(); + Map<String,String> userAttributes = new HashMap<String,String>(); - Map userInfo = new HashMap(); + Map<String,String> userInfo = new HashMap<String,String>(); ResourceBundle resource = getPortletConfig().getResourceBundle( actionRequest.getLocale()); @@ -592,15 +572,14 @@ public class UserRegistrationPortlet ext if (this.optionForceEmailAsUsername) { // email is something special - if (!ValidationHelper.isEmailAddress((String) userInfo - .get(USER_ATTRIBUTE_EMAIL), true, 80)) + if (!ValidationHelper.isEmailAddress(userInfo.get(USER_ATTRIBUTE_EMAIL), true, 80)) { errors.add(resource.getString("error.invalid-format." + USER_ATTRIBUTE_EMAIL)); } } else { - if (!ValidationHelper.isAny((String) userInfo.get("user.name"), + if (!ValidationHelper.isAny(userInfo.get("user.name"), true, 80)) { errors.add(resource.getString("error.lacking.user.name")); @@ -610,7 +589,7 @@ public class UserRegistrationPortlet ext // if we're not generating make sure it's real if (!this.optionForceGeneratedPasswords) { - if (!ValidationHelper.isAny((String) userInfo.get("password"), + if (!ValidationHelper.isAny(userInfo.get("password"), true, 25)) { errors.add(resource.getString("error.lacking.password")); @@ -626,7 +605,7 @@ public class UserRegistrationPortlet ext boolean userIdExistsFlag = true; try { - userManager.getUser((String) userInfo.get("user.name")); + userManager.getUser(userInfo.get("user.name")); } catch (SecurityException e) { userIdExistsFlag = false; @@ -644,8 +623,7 @@ public class UserRegistrationPortlet ext User user = null; try { - user = admin.lookupUserFromEmail((String) userInfo - .get(USER_ATTRIBUTE_EMAIL)); + user = admin.lookupUserFromEmail(userInfo.get(USER_ATTRIBUTE_EMAIL)); } catch (AdministrationEmailException e1) { emailExistsFlag = false; @@ -704,16 +682,16 @@ public class UserRegistrationPortlet ext String subsiteRootFolder = prefs.getValue("subsiteRootFolder", ""); if (subsiteRootFolder.trim().length() == 0) subsiteRootFolder = null; - List prefRoles = getPreferencesList(prefs, IP_ROLES); + List<String> prefRoles = getPreferencesList(prefs, IP_ROLES); if (prefRoles.isEmpty()) prefRoles = this.roles; - List prefGroups = getPreferencesList(prefs, IP_GROUPS); + List<String> prefGroups = getPreferencesList(prefs, IP_GROUPS); if (prefGroups.isEmpty()) prefGroups = this.groups; - List names = getPreferencesList(prefs, IP_RULES_NAMES); - List values = getPreferencesList(prefs, IP_RULES_VALUES); - Map profileRules = new HashMap(); + List<String> names = getPreferencesList(prefs, IP_RULES_NAMES); + List<String> values = getPreferencesList(prefs, IP_RULES_VALUES); + Map<String,String> profileRules = new HashMap<String,String>(); for (int ix = 0; ix < ((names.size() < values.size()) ? names.size() : values.size()); ix++) { @@ -722,16 +700,15 @@ public class UserRegistrationPortlet ext if (profileRules.isEmpty()) profileRules = this.rules; - admin.registerUser((String) userInfo.get("user.name"), - (String) userInfo.get("password"), prefRoles, + admin.registerUser( userInfo.get("user.name"), + userInfo.get("password"), prefRoles, prefGroups, userAttributes, // note use of only // PLT.D values here. profileRules, template, subsiteRootFolder, actionRequest.getLocale(), actionRequest.getServerName()); String urlGUID = ForgottenPasswordPortlet.makeGUID( - (String) userInfo.get("user.name"), (String) userInfo - .get("password")); + userInfo.get("user.name"), userInfo.get("password")); userInfo.put(CTX_RETURN_URL, generateReturnURL(actionRequest, actionResponse, urlGUID)); @@ -744,8 +721,7 @@ public class UserRegistrationPortlet ext boolean sendEmail = prefs.getValue("SendEmail", "true").equals("true"); if (sendEmail) { - admin.sendEmail(getPortletConfig(), (String) userInfo - .get(USER_ATTRIBUTE_EMAIL), + admin.sendEmail(getPortletConfig(), userInfo.get(USER_ATTRIBUTE_EMAIL), getEmailSubject(actionRequest), templ, userInfo); } @@ -803,10 +779,10 @@ public class UserRegistrationPortlet ext return this.emailSubject; } - protected List getInitParameterList(PortletConfig config, String ipName) + protected List<String> getInitParameterList(PortletConfig config, String ipName) { String temp = config.getInitParameter(ipName); - if (temp == null) return new ArrayList(); + if (temp == null) return new ArrayList<String>(); String[] temps = temp.split("\\,"); for (int ix = 0; ix < temps.length; ix++) @@ -815,10 +791,10 @@ public class UserRegistrationPortlet ext return Arrays.asList(temps); } - protected List getPreferencesList(PortletPreferences prefs, String prefName) + protected List<String> getPreferencesList(PortletPreferences prefs, String prefName) { String temp = prefs.getValue(prefName, ""); - if (temp == null || temp.trim().length() == 0) return new ArrayList(); + if (temp == null || temp.trim().length() == 0) return new ArrayList<String>(); String[] temps = temp.split("\\,"); for (int ix = 0; ix < temps.length; ix++) Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java?rev=1507158&r1=1507157&r2=1507158&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java Fri Jul 26 00:10:06 2013 @@ -16,16 +16,6 @@ */ package org.apache.jetspeed.portlets.security; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import javax.portlet.PortletRequest; -import javax.portlet.ReadOnlyException; -import javax.portlet.ValidatorException; - import org.apache.commons.lang.StringUtils; import org.apache.jetspeed.om.folder.Folder; import org.apache.jetspeed.om.folder.FolderNotFoundException; @@ -49,6 +39,15 @@ import org.apache.wicket.model.ResourceM import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.portlet.PortletRequest; +import javax.portlet.ReadOnlyException; +import javax.portlet.ValidatorException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + /** * @author vkumar <a href="vku...@apache.org">Vivek Kumar</a> */ @@ -233,7 +232,7 @@ public class JetspeedPrincipalManagement } /** - * @param subSiteRootr + * @param subSiteRoot * the subSiteRootr to set */ public void setSubSiteRoot(String subSiteRoot) @@ -243,11 +242,11 @@ public class JetspeedPrincipalManagement private List<String> getProfiles() { - ArrayList<String> profileList = new ArrayList<String>(); - List profileRules = (List) ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getProfiler().getRules(); + ArrayList <String> profileList = new ArrayList<String>(); + List<ProfilingRule> profileRules = (List<ProfilingRule>) ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getProfiler().getRules(); for (int counter = 0; counter < profileRules.size(); counter++) { - profileList.add(((ProfilingRule) profileRules.get(counter)).getId()); + profileList.add((profileRules.get(counter)).getId()); } return profileList; } Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java?rev=1507158&r1=1507157&r2=1507158&view=diff ============================================================================== --- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java (original) +++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java Fri Jul 26 00:10:06 2013 @@ -16,20 +16,6 @@ */ package org.apache.jetspeed.portlets.security; -import java.io.Serializable; -import java.security.Principal; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import javax.portlet.PortletPreferences; -import javax.security.auth.Subject; - import org.apache.commons.lang.StringUtils; import org.apache.jetspeed.administration.PortalConfigurationConstants; import org.apache.jetspeed.audit.AuditActivity; @@ -103,6 +89,19 @@ import org.apache.wicket.validation.vali import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.portlet.PortletPreferences; +import javax.security.auth.Subject; +import java.io.Serializable; +import java.security.Principal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + /** * @author vkumar <a href="vku...@apache.org">Vivek Kumar</a> */ @@ -372,21 +371,19 @@ public class JetspeedPrincipalManagement { try { - Collection rules = getServiceLocator().getProfiler() + Collection<PrincipalRule> rules = getServiceLocator().getProfiler() .getRulesForPrincipal(getPrincipal()); - for (Iterator it = getUserRules().iterator(); it - .hasNext();) + for (Iterator it = getUserRules().iterator(); it.hasNext();) { Map ruleMap = (Map) it.next(); if (Boolean.TRUE.equals(ruleMap.get("checked"))) { String locatorName = ((PrincipalRule) ruleMap .get("rule")).getLocatorName(); - for (Iterator ruleIter = rules.iterator(); ruleIter + for (Iterator<PrincipalRule> ruleIter = rules.iterator(); ruleIter .hasNext();) { - PrincipalRule rule = (PrincipalRule) ruleIter - .next(); + PrincipalRule rule = ruleIter.next(); if (rule.getLocatorName().equals( locatorName)) { @@ -539,11 +536,8 @@ public class JetspeedPrincipalManagement } if (getPrincipal() != null) { - for (Iterator it = getServiceLocator().getProfiler() - .getRulesForPrincipal(getPrincipal()).iterator(); it - .hasNext();) + for (PrincipalRule rule : getServiceLocator().getProfiler().getRulesForPrincipal(getPrincipal())) { - PrincipalRule rule = (PrincipalRule) it.next(); Map ruleMap = new HashMap(); ruleMap.put("rule", rule); ruleMap.put("checked", Boolean.FALSE); --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscr...@portals.apache.org For additional commands, e-mail: jetspeed-dev-h...@portals.apache.org