portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile BaseProfileLocator.java ProfileLocator.java
Date Wed, 03 Jul 2002 02:15:07 GMT
taylor      2002/07/02 19:15:07

  Modified:    src/java/org/apache/jetspeed/om/profile
                        BaseProfileLocator.java ProfileLocator.java
  Log:
  Added getPath() which returns the path of the Profile.
  
  Revision  Changes    Path
  1.14      +86 -22    jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/BaseProfileLocator.java
  
  Index: BaseProfileLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/BaseProfileLocator.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BaseProfileLocator.java	28 Jun 2002 05:37:30 -0000	1.13
  +++ BaseProfileLocator.java	3 Jul 2002 02:15:07 -0000	1.14
  @@ -102,12 +102,12 @@
        *
        *   <username>/<mediaType>/<language>/<country>/<page>
        *   <group>/<mediaType>/<language>/<country>/<page>
  -     *   <role>/<mediaType>/<language>/<country>/<page> 
 
  +     *   <role>/<mediaType>/<language>/<country>/<page>
  +     *
        *
  -     * 
        * @return The profile locator id
        */
  -   
  +
       public String getId()
       {
           StringBuffer id = new StringBuffer(128);
  @@ -125,7 +125,7 @@
           else if (role != null)
           {
               id.append(Profiler.PARAM_ROLE).append(DELIM);
  -            id.append(role.getName());        
  +            id.append(role.getName());
           }
           else
           {
  @@ -151,7 +151,71 @@
               id.append(DELIM);
               id.append(name);
           }
  -        
  +
  +        return id.toString();
  +    }
  +
  +
  +    /*
  +     * Gets the unique profile locator path, which is a combination of the name
  +     * value pairs. This ID must follow the one of the 4 sequences below:
  +     *
  +     *   user/<name>/media-type/<mediaType>/language/<language>
  +     *               /country/<country>/<page>/page
  +     *
  +     *   group/ ""
  +     *   role/  ""
  +     *
  +     *
  +     * @return The profile locator path
  +     */
  +
  +    public String getPath()
  +    {
  +        StringBuffer id = new StringBuffer(128);
  +
  +        if (!anonymous && user != null)
  +        {
  +            id.append(Profiler.PARAM_USER).append(DELIM);
  +            id.append(user.getUserName()).append(DELIM);
  +        }
  +        else if (group != null)
  +        {
  +            id.append(Profiler.PARAM_GROUP).append(DELIM);
  +            id.append(group.getName()).append(DELIM);
  +        }
  +        else if (role != null)
  +        {
  +            id.append(Profiler.PARAM_ROLE).append(DELIM);
  +            id.append(role.getName()).append(DELIM);
  +        }
  +        else
  +        {
  +            id.append(Profiler.PARAM_USER).append(DELIM);
  +            id.append(Profiler.PARAM_ANON).append(DELIM);
  +        }
  +
  +        if (language != null)
  +        {
  +            id.append(Profiler.PARAM_LANGUAGE).append(DELIM);
  +            id.append(language).append(DELIM);
  +        }
  +        if (country != null)
  +        {
  +            id.append(Profiler.PARAM_COUNTRY).append(DELIM);
  +            id.append(country).append(DELIM);
  +        }
  +        if (mediaType != null)
  +        {
  +            id.append(Profiler.PARAM_MEDIA_TYPE).append(DELIM);
  +            id.append(mediaType).append(DELIM);
  +        }
  +        if (name != null)
  +        {
  +            id.append(Profiler.PARAM_PAGE).append(DELIM);
  +            id.append(name).append(DELIM);
  +        }
  +        id.deleteCharAt(id.length()-1);
           return id.toString();
       }
   
  @@ -178,7 +242,7 @@
                   try
                   {
                       this.setUser( JetspeedSecurity.getUser(tok.nextToken()) );
  -                }               
  +                }
                   catch (Exception e)
                   {
                       Log.error("ProfileLocator: Failed to set User: " + e);
  @@ -189,7 +253,7 @@
                   try
                   {
                       this.setGroup( JetspeedSecurity.getGroup(tok.nextToken()) );
  -                }               
  +                }
                   catch (Exception e)
                   {
                       Log.error("ProfileLocator: Failed to set Group: " + e);
  @@ -200,7 +264,7 @@
                   try
                   {
                       this.setRole( JetspeedSecurity.getRole(tok.nextToken()) );
  -                }               
  +                }
                   catch (Exception e)
                   {
                       Log.error("ProfileLocator: Failed to set Role: " + e);
  @@ -213,7 +277,7 @@
               else if (name.equals(Profiler.PARAM_MEDIA_TYPE) && tok.hasMoreTokens())
               {
                   this.setMediaType(tok.nextToken());
  -            }            
  +            }
               else if (name.equals(Profiler.PARAM_LANGUAGE) && tok.hasMoreTokens())
               {
                   this.setLanguage(tok.nextToken());
  @@ -221,15 +285,15 @@
               else if (name.equals(Profiler.PARAM_COUNTRY) && tok.hasMoreTokens())
               {
                   this.setCountry(tok.nextToken());
  -            }            
  +            }
   
  -        }      
  +        }
       }
   
  -   /**    
  +   /**
        * @see Object#clone
        * @return an instance copy of this object
  -     */    
  +     */
       public Object clone() throws java.lang.CloneNotSupportedException
       {
           return super.clone();
  @@ -419,7 +483,7 @@
       public void setRoleByName( String roleName )
       {
           try
  -        {        
  +        {
               Role temp = JetspeedSecurity.getRole(roleName);
               if (null != temp)
               {
  @@ -518,14 +582,14 @@
       }
   
       /**
  -     * Check equality for given User object with this ProfileLocator's User 
  +     * Check equality for given User object with this ProfileLocator's User
        * object.
        */
       private boolean userEquals(ProfileLocator locator)
       {
           JetspeedUser user = locator.getUser();
           // if either of reference is null return false.
  -        if (exclusiveOr(this.user, user)) 
  +        if (exclusiveOr(this.user, user))
           {
               return false;
           }
  @@ -539,13 +603,13 @@
       }
   
       /**
  -     * Check equality for given Group object with this ProfileLocator's Group 
  +     * Check equality for given Group object with this ProfileLocator's Group
        * object.
        */
       private boolean groupEquals(Group group)
       {
           // if either of reference is null return false.
  -        if (exclusiveOr(this.group, group)) 
  +        if (exclusiveOr(this.group, group))
           {
               return false;
           }
  @@ -559,13 +623,13 @@
       }
   
       /**
  -     * Check equality for given Role object with this ProfileLocator's Role 
  +     * Check equality for given Role object with this ProfileLocator's Role
        * object.
        */
       private boolean roleEquals(Role role)
       {
           // if either of reference is null return false.
  -        if (exclusiveOr(this.role, role)) 
  +        if (exclusiveOr(this.role, role))
           {
               return false;
           }
  @@ -619,7 +683,7 @@
        */
       private boolean stringEquals(String str1, String str2)
       {
  -        if (exclusiveOr(str1, str2)) 
  +        if (exclusiveOr(str1, str2))
           {
               return false;
           }
  
  
  
  1.7       +19 -5     jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/ProfileLocator.java
  
  Index: ProfileLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/ProfileLocator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProfileLocator.java	28 Jun 2002 05:37:30 -0000	1.6
  +++ ProfileLocator.java	3 Jul 2002 02:15:07 -0000	1.7
  @@ -89,13 +89,27 @@
        *
        *   <username>/<mediaType>/<language>/<country>/<page>
        *   <group>/<mediaType>/<language>/<country>/<page>
  -     *   <role>/<mediaType>/<language>/<country>/<page> 
 
  +     *   <role>/<mediaType>/<language>/<country>/<page>
        *
        * @return The profile locator id
        */
       String getId();
   
       /*
  +     * Gets the unique profile locator path, which is a combination of the params
  +     * This Path must follow the one of the 4 sequences below:
  +     *
  +    *   user/<name>/media-type/<mediaType>/language/<language>
  +    *               /country/<country>/<page>/page
  +    *
  +    *   group/ ""
  +    *   role/  ""
  +     *
  +     * @return The profile locator path
  +     */
  +    String getPath();
  +
  +    /*
        * Gets the resource name parameter for this profile.
        *
        * @return The resource name parameter for this profile.
  @@ -216,7 +230,7 @@
        * @return The group parameter for this profile.
        */
       Group getGroup();
  -    
  +
       String getGroupName();
   
       /*
  @@ -228,10 +242,10 @@
   
       void setGroupByName( String groupName );
   
  -   /** 
  +   /**
        * @see Object#clone
        * @return an instance copy of this object
  -     */    
  +     */
       Object clone() throws java.lang.CloneNotSupportedException;
   
   }
  
  
  

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


Mime
View raw message