Package com.sun.identity.shared.search
Class FileLookup
- java.lang.Object
-
- com.sun.identity.shared.search.FileLookup
-
public class FileLookup extends Object
This class provides a generic file path generation utility for data file types, be it template, JSP, or property. FileLookup should follow the same look up pattern of the Java Resource Bundle Lookup. Failure to do so results in messages in mixed languages. With the Java lookup mechanism, if the platform locale is ja_JP and the Resource Bundle locale is zh_CN, the lookup sequence is rb_zh_CN, rb_zh, rb_JA_JP, rb_ja, rb. We can not fall back to rb if the zh resource bundle is not found. Hence, we have added more steps to file lookup
-
-
Constructor Summary
Constructors Constructor Description FileLookup()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilegetFirstExisting(String type, String locale, String component, String clientPath, String filename, String templateDir, boolean enableCache)Return the first existing file in the ordered search paths.static FilegetFirstExisting(String type, String locale, String component, String orgFilePath, String clientPath, String filename, String templateDir, boolean enableCache)Returns the first existing file in the ordered search paths.static StringgetFirstExistingRemote(String server, String type, String locale, String filename)Returns the first existing url found on the remote server.static File[]getOrderedPaths(String type, String locale, String component, String orgPath, String clientPath, String filename)Returns all possible paths for the specified file in an ordered array.
-
-
-
Method Detail
-
getOrderedPaths
public static File[] getOrderedPaths(String type, String locale, String component, String orgPath, String clientPath, String filename) throws FileLookupException
Returns all possible paths for the specified file in an ordered array. If all parameters specified are non-null, then the order of the filepaths is generated in the following manner:_ / / / _ / / _ / / / / _ / / / _ / / _ / Repeat pattern above, taking off the ending "_xx" portion of the locale. For example, if the original value was "jp_JP_WIN", then the above would be _jp_JP_WIN. The next groups would be _jp_JP and _jp. If the platform locale is different from the specified locale, then the pattern for is repeated with the platform locale, with the addition of using no "_ " (i.e., the last set consists of " /..."). Additionally, "default" is used as " ", and the above patterns are repeated. - Parameters:
type- The base filepath to begin the search. If null, "default" is the start of the filepath.locale- The locale for the file of interest.component- The component part of the filepath, if any.orgPath- The organization part of the filepath, if any.clientPath- The client type for that part of the filepathfilename- The filename of interest- Returns:
File[]of ordered search paths.- Throws:
FileLookupException
-
getFirstExisting
public static File getFirstExisting(String type, String locale, String component, String clientPath, String filename, String templateDir, boolean enableCache) throws FileLookupException
Return the first existing file in the ordered search paths.- Parameters:
type- An arbitrary profile-stored stringlocale- The locale for the file of interest.component- The component part of the filepath, if any.clientPath- The client type for that part of the filepathfilename- The filename of interesttemplateDir-enableCache-- Returns:
- first existing file in the ordered search paths.
- Throws:
FileLookupException
-
getFirstExisting
public static File getFirstExisting(String type, String locale, String component, String orgFilePath, String clientPath, String filename, String templateDir, boolean enableCache) throws FileLookupException
Returns the first existing file in the ordered search paths.- Parameters:
type- The base filepath to begin the search.locale- The locale for the file of interest.component- The component part of the filepath, if any.clientPath- The client type for that part of the filepath.orgFilePath- The organization part of the filepath.filename- The filename of interesttemplateDir- The base template filepath to prepend.enableCache- True if the File object is to be cached.- Returns:
- first existing file in the ordered search paths.
- Throws:
FileLookupException
-
getFirstExistingRemote
public static String getFirstExistingRemote(String server, String type, String locale, String filename) throws FileLookupException
Returns the first existing url found on the remote server. The search is done based on the users locale. If no document is found in the users locale the default locale will be searched.- Parameters:
server- Server where document is locatedtype- The base filepath to begin the search.locale- The locale for the file of interest.filename- The filename of interest.- Returns:
- url of document, or null if no document was found.
- Throws:
FileLookupException
-
-