You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/08/12 01:56:28 UTC

cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/userinfo/impl AbstractUserInfoManagerImpl.java UserInfoManagerImpl.java

taylor      2004/08/11 16:56:28

  Modified:    portal/src/java/org/apache/jetspeed/userinfo/impl
                        UserInfoManagerImpl.java
  Added:       portal/src/java/org/apache/jetspeed/userinfo/impl
                        AbstractUserInfoManagerImpl.java
  Log:
  refactored UserInfoManagerImpl to use common code in base abstract class
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.6       +2 -63     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
  
  Index: UserInfoManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UserInfoManagerImpl.java	8 Jun 2004 01:35:26 -0000	1.5
  +++ UserInfoManagerImpl.java	11 Aug 2004 23:56:28 -0000	1.6
  @@ -15,7 +15,6 @@
   package org.apache.jetspeed.userinfo.impl;
   
   import java.security.Principal;
  -import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.HashMap;
  @@ -31,9 +30,7 @@
   
   import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
  -import org.apache.jetspeed.om.common.UserAttribute;
   import org.apache.jetspeed.om.common.UserAttributeRef;
  -import org.apache.jetspeed.om.impl.UserAttributeRefImpl;
   import org.apache.jetspeed.request.RequestContext;
   import org.apache.jetspeed.security.User;
   import org.apache.jetspeed.security.UserManager;
  @@ -51,8 +48,9 @@
    * </p>
    * 
    * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
  + * @version $Id$
    */
  -public class UserInfoManagerImpl implements UserInfoManager
  +public class UserInfoManagerImpl extends AbstractUserInfoManagerImpl implements UserInfoManager
   {
   
       /** Logger */
  @@ -226,65 +224,6 @@
           return userInfoMap;
       }
   
  -    /**
  -     * <p>
  -     * Return the linked attributes mapping portlet user attributes to portal
  -     * user attributes.
  -     * </p>
  -     * 
  -     * @param userAttributes
  -     *            The declarative portlet user attributes.
  -     * @param userAttributeRefs
  -     *            The declarative jetspeed portlet extension user attributes
  -     *            reference.
  -     * @return The collection of linked attributes.
  -     */
  -    private Collection mapLinkedUserAttributes(Collection userAttributes, Collection userAttributeRefs)
  -    {
  -        Collection linkedUserAttributes = new ArrayList();
  -        if ((null != userAttributeRefs) && (userAttributeRefs.size() > 0))
  -        {
  -            Iterator attrIter = userAttributes.iterator();
  -            while (attrIter.hasNext())
  -            {
  -                UserAttribute currentAttribute = (UserAttribute) attrIter.next();
  -                boolean linkedAttribute = false;
  -                if (null != currentAttribute)
  -                {
  -                    Iterator attrRefsIter = userAttributeRefs.iterator();
  -                    while (attrRefsIter.hasNext())
  -                    {
  -                        UserAttributeRef currentAttributeRef = (UserAttributeRef) attrRefsIter.next();
  -                        if (null != currentAttributeRef)
  -                        {
  -                            if ((currentAttribute.getName()).equals(currentAttributeRef.getNameLink()))
  -                            {
  -                                if (log.isDebugEnabled())
  -                                    log.debug("Linking user attribute ref: [[name, " + currentAttribute.getName()
  -                                            + "], [linked name, " + currentAttributeRef.getName() + "]]");
  -                                linkedUserAttributes.add(currentAttributeRef);
  -                                linkedAttribute = true;
  -                            }
  -                        }
  -                    }
  -                }
  -                if (!linkedAttribute)
  -                {
  -                    linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute));
  -                }
  -            }
  -        }
  -        else
  -        {
  -            Iterator attrIter = userAttributes.iterator();
  -            while (attrIter.hasNext())
  -            {
  -                UserAttribute currentAttribute = (UserAttribute) attrIter.next();
  -                linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute));
  -            }
  -        }
  -        return linkedUserAttributes;
  -    }
   
       /**
        * <p>
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/userinfo/impl/AbstractUserInfoManagerImpl.java
  
  Index: AbstractUserInfoManagerImpl.java
  ===================================================================
  /* Copyright 2004 Apache Software Foundation
  *
  * 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 org.apache.jetspeed.userinfo.impl;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.jetspeed.om.common.UserAttribute;
  import org.apache.jetspeed.om.common.UserAttributeRef;
  import org.apache.jetspeed.om.impl.UserAttributeRefImpl;
  
  /**
   * <p> Common user info management support
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   * @version $Id: AbstractUserInfoManagerImpl.java,v 1.1 2004/08/11 23:56:28 taylor Exp $
   */
  public abstract class AbstractUserInfoManagerImpl
  {
      /** Logger */
      private static final Log log = LogFactory.getLog(UserInfoManagerImpl.class);
      
      /**
       * <p>
       * Return the linked attributes mapping portlet user attributes to portal
       * user attributes.
       * </p>
       * 
       * @param userAttributes
       *            The declarative portlet user attributes.
       * @param userAttributeRefs
       *            The declarative jetspeed portlet extension user attributes
       *            reference.
       * @return The collection of linked attributes.
       */
      protected Collection mapLinkedUserAttributes(Collection userAttributes, Collection userAttributeRefs)
      {
          Collection linkedUserAttributes = new ArrayList();
          if ((null != userAttributeRefs) && (userAttributeRefs.size() > 0))
          {
              Iterator attrIter = userAttributes.iterator();
              while (attrIter.hasNext())
              {
                  UserAttribute currentAttribute = (UserAttribute) attrIter.next();
                  boolean linkedAttribute = false;
                  if (null != currentAttribute)
                  {
                      Iterator attrRefsIter = userAttributeRefs.iterator();
                      while (attrRefsIter.hasNext())
                      {
                          UserAttributeRef currentAttributeRef = (UserAttributeRef) attrRefsIter.next();
                          if (null != currentAttributeRef)
                          {
                              if ((currentAttribute.getName()).equals(currentAttributeRef.getNameLink()))
                              {
                                  if (log.isDebugEnabled())
                                      log.debug("Linking user attribute ref: [[name, " + currentAttribute.getName()
                                              + "], [linked name, " + currentAttributeRef.getName() + "]]");
                                  linkedUserAttributes.add(currentAttributeRef);
                                  linkedAttribute = true;
                              }
                          }
                      }
                  }
                  if (!linkedAttribute)
                  {
                      linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute));
                  }
              }
          }
          else
          {
              Iterator attrIter = userAttributes.iterator();
              while (attrIter.hasNext())
              {
                  UserAttribute currentAttribute = (UserAttribute) attrIter.next();
                  linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute));
              }
          }
          return linkedUserAttributes;
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org