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/services/profiler ProfileManagerService.java ProfileManager.java JetspeedProfileManagerService.java
Date Wed, 25 Apr 2001 00:03:07 GMT
taylor      01/04/24 17:03:07

  Modified:    src/java/org/apache/jetspeed/services/profiler
                        ProfileManagerService.java ProfileManager.java
                        JetspeedProfileManagerService.java
  Log:
  - implemented NLS support using directories (not suffixes)
  - the anonymous directory is now hardcoded to psml/anon as per Santiago's suggestion
  - improved newAccount/creation of default resource
  - tested with customizer, seems to work for html
  - still need to test more for wml support
  
  Revision  Changes    Path
  1.8       +54 -8     jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfileManagerService.java
  
  Index: ProfileManagerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfileManagerService.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProfileManagerService.java	2001/03/07 06:49:00	1.7
  +++ ProfileManagerService.java	2001/04/25 00:03:06	1.8
  @@ -67,7 +67,7 @@
    * 
    * @see org.apache.jetspeed.om.profile.Profile
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: ProfileManagerService.java,v 1.7 2001/03/07 06:49:00 taylor Exp $
  + * @version $Id: ProfileManagerService.java,v 1.8 2001/04/25 00:03:06 taylor Exp $
    */
   
   public interface ProfileManagerService extends Service
  @@ -83,8 +83,8 @@
        * @param rundata the rundata object for the current request
        * @return a Profile object if found by the manager or null
        */
  -    public Profile getProfile(RunData rundata, CapabilityMap cm);
  -
  +    public Profile getProfile(RunData rundata, CapabilityMap cm)
  +        throws ProfileException;
        /**
         * sets a profile as the current profile for this session
         *
  @@ -100,7 +100,8 @@
        * @param rundata the rundata object for the current request
        * @return a new Profile object
        */
  -    public Profile getProfile(RunData rundata);
  +    public Profile getProfile(RunData rundata)
  +                throws ProfileException;
   
       /**
        * get the Profile object using the Rundata state and capability map
  @@ -109,7 +110,8 @@
        * @param rundata the rundata object for the current request
        * @return a new Profile object
        */
  -    public Profile getProfile(RunData data, MimeType mt);
  +    public Profile getProfile(RunData data, MimeType mt)
  +        throws ProfileException;
   
        /**
         * gets the current profile for this session
  @@ -117,7 +119,8 @@
         * @param rundata the rundata object for the current request
         * @param profile the profile object to set in the session context
         */
  -    public Profile getSessionProfile(RunData rundata);
  +    public Profile getSessionProfile(RunData rundata)
  +        throws ProfileException;
   
       /**
        *  create a user profile and its resources (psml) for a new user
  @@ -127,14 +130,15 @@
        * @return a new Profile object
        */
       public Profile createUserProfile(RunData rundata, String userName)
  -        throws IOException;
  +        throws IOException, ProfileException;
   
        /**
         * stores a cookie in response to the current resource
         *
         * @param rundata the rundata object for the current request
         */
  -     public DynamicURI makeDynamicURI( RunData data );
  +     public DynamicURI makeDynamicURI( RunData data )
  +        throws ProfileException;
   
        /**
         * stores a cookie in response to the current resource
  @@ -142,5 +146,47 @@
         * @param rundata the rundata object for the current request
         */
        public void storeCookie(RunData rundata);
  +
  +    /**
  +     *  turn on/off security checking when accessing profile resources
  +     *
  +     * @param flag indicates to turn security on with true, off with false.
  +     */
  +    public void setSecurity( boolean flag );
  +
  +    /**
  +     *  get status of security checking when accessing profile resources
  +     *
  +     * @return the security-checking status: true in on, false is off
  +     */
  +    public boolean getSecurity();
  +
  +    /**
  +     *  turn on/off NLS (language support) when accessing profile resources
  +     *
  +     * @param flag indicates to turn NLS on with true, off with false.
  +     */
  +    public void setLanguageProfiling( boolean flag );
  +
  +    /**
  +     *  get status of NLS (language support) when accessing profile resources
  +     *
  +     * @return the language profiling status: true in on, false is off
  +     */
  +    public boolean getLanguageProfiling();
  +
  +    /**
  +     *  turn on/off caching of resource names
  +     *
  +     * @param flag indicates to turn caching on with true, off with false.
  +     */
  +    public void setResourceNameCaching( boolean flag );
  +
  +    /**
  +     *  get status of caching of resource names
  +     *
  +     * @return the resource caching status: true in on, false is off
  +     */
  +    public boolean getResourceNameCaching();
   
   }
  
  
  
  1.8       +72 -9     jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfileManager.java
  
  Index: ProfileManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfileManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProfileManager.java	2001/03/07 06:48:59	1.7
  +++ ProfileManager.java	2001/04/25 00:03:06	1.8
  @@ -70,7 +70,7 @@
    * @see org.apache.jetspeed.services.profiler.Profiler
    * @see org.apache.jetspeed.services.profiler.ProfilerManagerService
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: ProfileManager.java,v 1.7 2001/03/07 06:48:59 taylor Exp $
  + * @version $Id: ProfileManager.java,v 1.8 2001/04/25 00:03:06 taylor Exp $
    */
   public class ProfileManager
   {
  @@ -79,7 +79,8 @@
        * Commodity method for getting a reference to the service
        * singleton
        */
  -    private static ProfileManagerService getService() {
  +    private static ProfileManagerService getService()
  +    {
           return (ProfileManagerService)TurbineServices
                   .getInstance()
                   .getService(ProfileManagerService.SERVICE_NAME);
  @@ -88,14 +89,18 @@
       /**
        * @see ProfileManagerService#getProfile
        */
  -    public static Profile getProfile(RunData rundata, CapabilityMap cm) {
  +    public static Profile getProfile(RunData rundata, CapabilityMap cm)
  +        throws ProfileException
  +    {
          return getService().getProfile( rundata, cm );
       }
   
       /**
        * @see ProfileManagerService#getProfile
        */
  -    public static Profile getProfile(RunData rundata) {
  +    public static Profile getProfile(RunData rundata)
  +        throws ProfileException
  +    {
          return getService().getProfile( rundata );
       }
   
  @@ -103,6 +108,7 @@
        * @see ProfileManagerService#getProfile
        */
       public static Profile getProfile(RunData data, MimeType mt)
  +        throws ProfileException
       {
           return getService().getProfile( data, mt );
       }
  @@ -110,14 +116,17 @@
       /**
        * @see ProfileManagerService#setSessionProfile
        */
  -    public static void setSessionProfile(RunData rundata, Profile profile) {
  +    public static void setSessionProfile(RunData rundata, Profile profile)
  +    {
           getService().setSessionProfile( rundata, profile );
       }
   
       /**
        * @see ProfileManagerService#getSessionProfile
        */
  -    public static Profile getSessionProfile(RunData rundata) {
  +    public static Profile getSessionProfile(RunData rundata)
  +        throws ProfileException
  +    {
           return getService().getSessionProfile( rundata );
       }
   
  @@ -125,7 +134,7 @@
        * @see ProfileManagerService#getSessionProfile
        */
       public static Profile createUserProfile(RunData rundata, String userName)
  -        throws IOException
  +        throws IOException, ProfileException
       {
           return getService().createUserProfile( rundata, userName );
       }
  @@ -133,12 +142,66 @@
       /**
        * @see ProfileManagerService#storeCookie
        */
  -    public static void storeCookie(RunData rundata) {
  +    public static void storeCookie(RunData rundata)
  +    {
          getService().storeCookie( rundata );
       }
   
  -     public static DynamicURI makeDynamicURI( RunData data ) {
  +    /**
  +     * @see ProfileManagerService#makeDynamicURI
  +     */
  +     public static DynamicURI makeDynamicURI( RunData data )
  +        throws ProfileException
  +     {
           return getService().makeDynamicURI( data );
        }
  +
  +    /**
  +     * @see ProfileManagerService#setSecurity
  +     */
  +    public void setSecurity( boolean flag )
  +    {
  +        getService().setSecurity(flag);
  +    }
  +
  +    /**
  +     * @see ProfileManagerService#getSecurity
  +     */
  +    public boolean getSecurity()
  +    {
  +        return getService().getSecurity();
  +    }
  +
  +    /**
  +     * @see ProfileManagerService#setLanguageProfiling
  +     */
  +    public void setLanguageProfiling( boolean flag )
  +    {
  +        getService().setLanguageProfiling(flag);
  +    }
  +
  +    /**
  +     * @see ProfileManagerService#getLanguageProfiling
  +     */
  +    public boolean getLanguageProfiling()
  +    {
  +        return getService().getLanguageProfiling();
  +    }
  +
  +    /**
  +     * @see ProfileManagerService#setResourceNameCaching
  +     */
  +    public void setResourceNameCaching( boolean flag )
  +    {
  +        getService().setResourceNameCaching(flag);
  +    }
  +
  +    /**
  +     * @see ProfileManagerService#getResourceNameCaching
  +     */
  +    public boolean getResourceNameCaching()
  +    {
  +        return getService().getResourceNameCaching();
  +    }
   
   }
  
  
  
  1.15      +209 -65   jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfileManagerService.java
  
  Index: JetspeedProfileManagerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfileManagerService.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JetspeedProfileManagerService.java	2001/04/20 07:34:34	1.14
  +++ JetspeedProfileManagerService.java	2001/04/25 00:03:06	1.15
  @@ -76,11 +76,18 @@
   import org.apache.turbine.util.DynamicURI;
   import org.apache.turbine.om.security.User;
   import org.apache.turbine.services.servlet.TurbineServlet;
  +import org.apache.turbine.services.localization.LocaleDetector;
  +import org.apache.turbine.services.resources.TurbineResources;
   
   //java stuff
  -import java.util.*;
  -import java.io.*;
  -import java.net.*;
  +import java.util.Map;
  +import java.util.HashMap;
  +import java.util.Enumeration;
  +import java.util.Locale;
  +import java.io.File;
  +import java.io.IOException;
  +import java.net.URL;
  +import java.net.MalformedURLException;
   import java.lang.reflect.Method;
   import javax.servlet.ServletConfig;
   
  @@ -93,8 +100,6 @@
    * <p>This service expects these properties to be set for correct operation:
    * <dl>
    *    <dt>root</dt><dd>The webapp rel. path to the root profiling directory</dd>
  - *    <dt>anon.dir</dt><dd>The webapp relative path to directory used
for
  - *     anonymous access</dd>
    *    <dt>resource.default</dt><dd>The default resource filename</dd>
    *    <dt>resource.ext</dt><dd>The default resource filename extension</dd>
    *    <dt>security</dt><dd>Use security flag</dd>
  @@ -104,7 +109,7 @@
    *
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
    * @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
  - * @version $Id: JetspeedProfileManagerService.java,v 1.14 2001/04/20 07:34:34 taylor Exp
$
  + * @version $Id: JetspeedProfileManagerService.java,v 1.15 2001/04/25 00:03:06 taylor Exp
$
    */
   
   public class JetspeedProfileManagerService  extends TurbineBaseService
  @@ -119,16 +124,17 @@
       public final static String TEMP_USER                = "temp_user";
       // configuration keys
       private final static String CONFIG_ROOT             = ".root";
  -    private final static String CONFIG_ANON_DIR         = ".anon.dir";
       private final static String CONFIG_RESOURCE_DEFAULT = ".resource.default";
       private final static String CONFIG_RESOURCE_EXT     = ".resource.ext";
       private final static String CONFIG_SECURITY         = ".security";
       private final static String CONFIG_LANGUAGE         = ".language";
  +    private final static String CONFIG_NAMECACHE        = ".namecache";
   
       // resource path constants
       private static final String PATH_GROUP              = "group/";
       private static final String PATH_ROLE               = "role/";
       private static final String PATH_USER               = "user/";
  +    private static final String PATH_ANON               = "anon/";
       protected static final String PATH_SEPARATOR        = "/";
       private static final String PATH_EXTENSION_DELIMITER = ".";
   
  @@ -139,13 +145,14 @@
       private final static String MSG_MISSING_PARAMETER =
           "JetspeedProfilerService initialization failed. Missing parameter:";
   
  +
       // configuration parameters
  -     String root;               // the root psml resource directory
  -     String anonDir;            // the default anonymous directory
  -     String resourceDefault;    // the default name for a resource
  -     String resourceExt;        // the default extension for a resource
  -     boolean useSecurity;       // use security features
  -     boolean useLanguage;       // use extended language mapping features
  +     String root;                   // the root psml resource directory
  +     String resourceDefault;        // the default name for a resource
  +     String resourceExt;            // the default extension for a resource
  +     boolean useSecurity = false;   // use security features
  +     boolean useLanguage = true;    // use extended language mapping features
  +     boolean useNameCache = true;   // use the cache to check existence of resources
   
       // lookup a media type based on mime-type
       private Map mediaMap = null;
  @@ -203,6 +210,66 @@
       }
   
       /**
  +     *  turn on/off security checking when accessing profile resources
  +     *
  +     * @param flag indicates to turn security on with true, off with false.
  +     */
  +    public void setSecurity( boolean flag )
  +    {
  +        useSecurity = flag;
  +    }
  +
  +    /**
  +     *  get status of security checking when accessing profile resources
  +     *
  +     * @return the security-checking status: true in on, false is off
  +     */
  +    public boolean getSecurity()
  +    {
  +        return useSecurity;
  +    }
  +
  +    /**
  +     *  turn on/off NLS (language support) when accessing profile resources
  +     *
  +     * @param flag indicates to turn NLS on with true, off with false.
  +     */
  +    public void setLanguageProfiling( boolean flag )
  +    {
  +        useLanguage = flag;
  +    }
  +
  +    /**
  +     *  get status of NLS (language support) when accessing profile resources
  +     *
  +     * @return the language profiling status: true in on, false is off
  +     */
  +    public boolean getLanguageProfiling()
  +    {
  +        return useLanguage;
  +    }
  +
  +    /**
  +     *  turn on/off caching of resource names
  +     *
  +     * @param flag indicates to turn caching on with true, off with false.
  +     */
  +    public void setResourceNameCaching( boolean flag )
  +    {
  +        useNameCache = flag;
  +    }
  +
  +    /**
  +     *  get status of caching of resource names
  +     *
  +     * @return the resource caching status: true in on, false is off
  +     */
  +    public boolean getResourceNameCaching()
  +    {
  +        return useNameCache;
  +    }
  +
  +    /**
        *  get the Profile object using the Rundata state and capability map
        *  this is the mapping functionality of the profiler
        *
  @@ -211,6 +278,7 @@
        * @return a new Profile object
        */
       public Profile getProfile(RunData rundata, CapabilityMap cm)
  +        throws ProfileException
       {
           Profile profile = getResourceURL(rundata, cm, true);
           this.setSessionProfile(rundata, profile);
  @@ -225,6 +293,7 @@
        * @return a new Profile object
        */
       public Profile getProfile(RunData rundata)
  +        throws ProfileException
       {
           CapabilityMap cm = CapabilityMapFactory.getCapabilityMap( rundata );
           Profile profile = getResourceURL(rundata, cm, true);
  @@ -240,6 +309,7 @@
        * @return a new Profile object
        */
       public Profile getProfile(RunData data, MimeType mt)
  +        throws ProfileException
       {
           CapabilityMap cm = CapabilityMapFactory.getCapabilityMap(mt.toString());
           Profile profile = getResourceURL(data, cm, false);
  @@ -266,6 +336,7 @@
         * @param profile the profile object to set in the session context
         */
       public Profile getSessionProfile(RunData rundata)
  +        throws ProfileException
       {
           // store the current profile in the session
           Profile profile = (Profile)rundata.getUser().getTemp(KEY_SESSION_PROFILE);
  @@ -284,7 +355,7 @@
        * @return a new Profile object
        */
       public Profile createUserProfile(RunData rundata, String userName)
  -        throws IOException
  +        throws IOException, ProfileException
       {
           CapabilityMap cm = CapabilityMapFactory.getCapabilityMap( rundata );
           // FIXME: this needs to be handled better for users/groups/roles
  @@ -293,7 +364,7 @@
           // get the media type from the capability map or rundata
           String mediaType = getMediaType(rundata, cm);
           BaseProfile profile = new BaseProfile();
  -        // get the target profile: by group/role/user
  +        // get the target profile
           String path = getPath(rundata, mediaType, profile);
           String resource = getResource(rundata, profile);
           String finalPath = root + path + resource;
  @@ -302,24 +373,32 @@
           if (!file.exists())
           {
               // copy from first psml resource found in fallback path
  -            Profile fallbackProfile = getResourceURL(rundata, cm, true);
  -            String  fallbackURL = fallbackProfile.getURL();
  -            String fallbackReal = null;
  +            Profile sourceProfile = getResourceURL(rundata, cm, true);
  +            String  sourceURL = sourceProfile.getURL();
  +            String sourceReal = null;
               try
               {
  -                fallbackReal = new URL(fallbackURL).getFile();
  +                sourceReal = new URL(sourceURL).getFile();
               }
               catch (MalformedURLException e)
               {
  -                fallbackReal = fallbackURL;
  +                if (sourceURL.startsWith("file:"))
  +                    sourceReal = sourceURL.substring(5);
  +                else
  +                    sourceReal = sourceURL;
               }
  +
               // make the directories and then copy it
               String parent = file.getParent();
               File filePath = new File(parent);
               filePath.mkdirs();
  -            FileCopy.copy( fallbackReal, realPath );
  +            FileCopy.copy( sourceReal, realPath );
           }
  -        profile.setURL(finalPath);
  +        URL url = TurbineServlet.getResource( finalPath );
  +        if (url != null)
  +            profile.setURL(url.toString());
  +        else
  +            profile.setURL(finalPath);
           this.setSessionProfile(rundata, profile);
           return profile;
       }
  @@ -341,6 +420,7 @@
        * @param cm the <code>CapabilityMap</code> of the current requesting device
        */
       private Profile getResourceURL(RunData rundata, CapabilityMap cm, boolean fallback)
  +        throws ProfileException
       {
           // get the media type from the capability map or rundata
           String mediaType = getMediaType(rundata, cm);
  @@ -356,39 +436,51 @@
           String original = path + resource;
           if (fallback)
           {
  -            while( (finalPath = fallback(path, resource)) == "") {
  +            while( (finalPath = fallback(rundata, path, resource)) == "") {
                   int pt = path.lastIndexOf(PATH_SEPARATOR);
                   if (-1 == pt)
                   {
                       path = "";  // look in psml root
  -                    finalPath = fallback(path, resource);
  +                    finalPath = fallback(rundata, path, resource);
                       if (finalPath == "")
                       {
  -                        String error = "Failed to find resource for " + original;
  -                        Log.error(error);
  -                        return profile;
  -                        //throw new ProfileException(error);
  +                        String errorMessage = "Failed to find resource for " + original;
  +                        throw new ProfileException(errorMessage);
                       }
                       break; // found default resource in root
                   }
  +                int length = path.length();
  +                if (pt == length - 1 && length > 1)
  +                {
  +                    //pt = pt - 1;
  +                    path = path.substring(0, pt);
  +                    pt = path.lastIndexOf(PATH_SEPARATOR);
  +                }
                   path = path.substring(0, pt);
               }
           }
           else
           {
  -            finalPath = fallback(path, resource);
  +            finalPath = fallback(rundata, path, resource);
               if (finalPath.length() == 0)
               {
                   finalPath = root + original;
  -                String url = TurbineServlet.getResource( finalPath ).toString();
  -                profile.setURL(url);
  +                URL url = TurbineServlet.getResource( finalPath );
  +                if (url != null)
  +                    profile.setURL(url.toString());
  +                else
  +                    profile.setURL(finalPath);
                   return profile;
               }
           }
           // TODO: ACL security
   
  -        String url = TurbineServlet.getResource( finalPath ).toString();
  -        profile.setURL(url);
  +         URL url = TurbineServlet.getResource( finalPath );
  +         if (url != null)
  +             profile.setURL(url.toString());
  +         else
  +             profile.setURL(finalPath);
  +
           return profile;
       }
   
  @@ -402,7 +494,9 @@
       protected String getPath(RunData rundata, String mediaType, BaseProfile profile)
       {
           if (null == rundata)
  -            return anonDir;
  +        {
  +            return PATH_ANON;
  +        }
   
           User user = rundata.getUser();
   
  @@ -435,14 +529,7 @@
                   }
                   else  // anonymous
                   {
  -                    path.append( anonDir );
  -                    String userName = rundata.getParameters().getString( TEMP_USER );
  -                    if (userName != null)
  -                    {
  -                        path.append(PATH_USER);
  -                        path.append(userName);
  -                        path.append(PATH_SEPARATOR);
  -                    }
  +                   path.append( PATH_ANON );
                   }
   
               }
  @@ -487,12 +574,6 @@
   
           String param = rundata.getParameters().getString( PARAM_PAGE );
   
  -        // TODO: language specific resources
  -        if (useLanguage) {
  -            String language = rundata.getRequest().getHeader("Accept-Language");
  -            //System.out.println("Language = " + language );
  -        }
  -
           if (null == param) {
              // the default resource
               resource.append( resourceDefault );
  @@ -516,24 +597,92 @@
        * @parameter path to the resource
        * @return a String the modified path to the resource based on fallback
        */
  -    protected String fallback(String path, String resource)
  +    protected String fallback(RunData rundata, String path, String resource)
       {
           StringBuffer fullPath = new StringBuffer( root );
   
           fullPath.append(path);
           if (!path.endsWith(PATH_SEPARATOR))
               fullPath.append(PATH_SEPARATOR);
  +
  +        // search for language specific resources at each level
  +        if (useLanguage && rundata != null) {
  +            //String language = rundata.getRequest().getHeader("Accept-Language");
  +            //System.out.println("**** Language = " + language );
  +            Locale locale = (Locale)rundata.getUser().getTemp("locale");
  +            if (locale == null)
  +            {
  +                  // Get the locale store it in the user object
  +                  locale = LocaleDetector.getLocale(rundata);
  +                  if (locale == null)
  +                  {
  +                      locale = new Locale(
  +                               TurbineResources.getString("locale.default.language", "en"),
  +                               TurbineResources.getString("locale.default.country", "US"));
  +                  }
  +                  rundata.getUser().setTemp("locale", locale);
  +            }
  +            String language = locale.getLanguage();
  +            String country = locale.getCountry();
  +            int count = 0;
  +            StringBuffer langPath = new StringBuffer();
  +            langPath.append( fullPath.toString() );
  +            if ((language != null) && (language.length() > 0))
  +            {
  +                langPath.append(language).append("/");
  +                count++;
  +            }
  +            if ((country != null) && (country.length() > 0))
  +            {
  +                langPath.append(country).append("/");
  +                count++;
  +            }
  +            String basePath = langPath.toString();
  +            String realPath, workingPath;
  +
  +            for ( ; count > 0 ; count--)
  +            {
  +               workingPath = basePath + resource;
  +               realPath = TurbineServlet.getRealPath( workingPath );
  +               if (resourceExists(realPath))
  +                   return workingPath;
  +                int pt = basePath.lastIndexOf(PATH_SEPARATOR);
  +                int length = basePath.length();
  +                if (-1 == pt)
  +                    break;
  +                if (pt == length - 1 && length > 1)
  +                {
  +                    //pt = pt - 1;
  +                    basePath = basePath.substring(0, pt);
  +                    pt = basePath.lastIndexOf(PATH_SEPARATOR);
  +                }
  +                basePath = basePath.substring(0, pt);
  +                basePath = basePath + PATH_SEPARATOR;
  +            }
  +        }
  +
           fullPath.append(resource);
           String realPath = TurbineServlet.getRealPath( fullPath.toString() );
  -
  -        if (resourceMap.containsKey(realPath))
  +    
  +        if (resourceExists(realPath))
               return fullPath.toString();  // found as is
   
  -        // TODO: language fallback
  -
           return "";
       }
   
  +    /**
  +     * checks for the existence of a resource given a key
  +     *
  +     * @parameter key the resource name.
  +     */
  +    public boolean resourceExists(String resourceKey)
  +    {
  +        if (useNameCache == true)
  +        {
  +            return resourceMap.containsKey(resourceKey);
  +        }
  +        return (new File(resourceKey).exists());
  +    }
   
       /**
        * initialize the mime-type-to-media-type map
  @@ -613,16 +762,6 @@
           if (!root.endsWith(PATH_SEPARATOR))
               root = root + PATH_SEPARATOR;
   
  -        anonDir = JetspeedResources.getString(TurbineServices.SERVICE_PREFIX
  -                                               + ProfileManagerService.SERVICE_NAME
  -                                               + CONFIG_ANON_DIR);
  -        if (anonDir == null)
  -            anonDir = new String("");
  -        else {
  -            if (anonDir.startsWith(PATH_SEPARATOR))
  -                anonDir = anonDir.substring(1);
  -        }
  -
           resourceDefault = JetspeedResources.getString(TurbineServices.SERVICE_PREFIX
                                                  + ProfileManagerService.SERVICE_NAME
                                                  + CONFIG_RESOURCE_DEFAULT);
  @@ -649,7 +788,11 @@
           useLanguage = JetspeedResources.getBoolean(TurbineServices.SERVICE_PREFIX
                                                  + ProfileManagerService.SERVICE_NAME
                                                  + CONFIG_LANGUAGE,
  -                                               false);
  +                                               true);
  +        useNameCache = JetspeedResources.getBoolean(TurbineServices.SERVICE_PREFIX
  +                                               + ProfileManagerService.SERVICE_NAME
  +                                               + CONFIG_NAMECACHE,
  +                                               true);
       }
   
       /**
  @@ -727,9 +870,10 @@
         * @return new dynamic URI with full path
         */
       public DynamicURI makeDynamicURI( RunData data )
  +        throws ProfileException
       {
           DynamicURI uri = new DynamicURI( data );
  -        BaseProfile profile = (BaseProfile)ProfileManager.getSessionProfile(data);
  +        BaseProfile profile = (BaseProfile)getSessionProfile(data);
           String group = profile.getGroup();
           if (null != group)
               uri.addPathInfo(PARAM_GROUP, group);
  
  
  

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


Mime
View raw message