ResourceLookup.java revision 8d2daf3b9ecfc9b9b306bab966eda82fe2201b19
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ResourceLookup.java,v 1.7 2009/05/02 22:12:04 kevinserwin Exp $
*
*/
/**
* ResourceLookup is a partial replacement for implementation of FileLookup. It
* performs the equivalent of "fstat" using ServletContext.getResource(), thus
* increasing web container independence.
*/
public class ResourceLookup {
/**
* Returns the first existing resource in the ordered search paths.
*
* @param context Servlet Context Reference.
* @param fileRoot
* @param locale
* @param orgFilePath
* @param clientPath
* @param filename
* @param resourceDir
* (absolute path of template base directory)
* @param enableCache
* (boolean on whether to cache previously returned files,
* restart required for changes when false)
* @return <code>String</code> first existing resource in the ordered
* search paths.
*/
boolean enableCache) {
.toString();
if (enableCache) {
if (resourceName != null
return resourceName;
} else {
}
}
}
// calls FileLookup to get the file paths to locate file
try {
orderedPaths[i].toString();
!= null)
{
break;
}
}
} catch (FileLookupException fe) {
} catch (Exception e) {
}
if (debug.messageEnabled()) {
}
if (resourceUrl != null) {
if (enableCache) {
if (resourceNameCache == null) {
resourceNameCache = new Hashtable();
}
}
} else {
resourceName = null;
}
return resourceName;
}
/* returns the resourceURL for the resource name for the request */
try {
}
if (resourceURL == null) {
// remove leading '/' from resourceName
}
} catch (Exception e) {
}
return resourceURL;
}
}