use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class Debug method initialize.
/**
* Initializes the Debug Service by locating the SPI implementations and
* instantiating the appropriate classes.
*/
private static synchronized void initialize() {
if (!serviceInitialized) {
String providerName = SystemPropertiesManager.get(DebugConstants.CONFIG_DEBUG_PROVIDER);
IDebugProvider provider = null;
boolean providerLoadFailed = false;
Exception exceptionCatched = null;
if (providerName != null && providerName.trim().length() > 0) {
try {
provider = (IDebugProvider) Class.forName(providerName).newInstance();
} catch (ClassNotFoundException cnex) {
providerLoadFailed = true;
exceptionCatched = cnex;
} catch (InstantiationException iex) {
providerLoadFailed = true;
exceptionCatched = iex;
} catch (IllegalAccessException iaex) {
providerLoadFailed = true;
exceptionCatched = iaex;
} catch (ClassCastException ccex) {
providerLoadFailed = true;
exceptionCatched = ccex;
}
}
if (provider == null) {
if (providerLoadFailed) {
ResourceBundle bundle = com.sun.identity.shared.locale.Locale.getInstallResourceBundle("amUtilMsgs");
StdDebugFile.printError(Debug.class.getSimpleName(), bundle.getString("com.iplanet" + ".services" + ".debug.invalidprovider"), exceptionCatched);
}
provider = new DebugProviderImpl();
}
setDebugProvider(provider);
serviceInitialized = true;
}
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class AMResourceBundleCache method getResBundle.
/**
* Returns resource bundle from cache.
*
* @param name Name of bundle.
* @param locale Localeof bundle.
* @return Resource bundle.
*/
public ResourceBundle getResBundle(String name, Locale locale) {
ResourceBundle resBundle = null;
Map map = (Map) mapBundles.get(name);
if (map != null) {
resBundle = (ResourceBundle) map.get(locale);
}
if (resBundle == null) {
try {
resBundle = ResourceBundle.getBundle(name, locale);
} catch (MissingResourceException mre) {
debug.error("AMResourceBundleCache.getResBundle", mre);
}
synchronized (mapBundles) {
if (map == null) {
map = new HashMap(5);
mapBundles.put(name, map);
}
map.put(locale, resBundle);
}
}
return resBundle;
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class EmailPassword method sendEmailToUser.
/**
* Sents reset password email to the user.
*
* @param emailAddres email address of the user
* @param password new password
*/
private void sendEmailToUser(String emailAddress, String password) throws MessagingException {
String[] obj = new String[1];
obj[0] = password;
ResourceBundle rb = PWResetResBundleCacher.getBundle(bundleName, userLocale);
String msg = MessageFormat.format(rb.getString("resetPassMail.message"), (Object[]) obj);
String subject = rb.getString("resetSubject.message");
String[] to = new String[1];
to[0] = emailAddress;
String from = rb.getString("fromAddress.label");
String charset = g11nSettings.getDefaultCharsetForLocale(userLocale);
AMSendMail sendMail = new AMSendMail();
sendMail.postMail(to, subject, msg, from, charset);
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class ResourceBundleTest method addResourceBundle.
@Parameters({ "bundle-name", "bundle-file-name", "locale" })
@Test(groups = { "cli-resource-bundle", "add-res-bundle" })
public void addResourceBundle(String bundleName, String fileName, String locale) throws CLIException, SSOException {
entering("addResourceBundle", null);
String[] args = (locale.length() == 0) ? new String[5] : new String[7];
args[0] = "add-res-bundle";
args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.RESOURCE_BUNDLE_NAME;
args[2] = bundleName;
args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + AddResourceBundle.ARGUMENT_RESOURCE_BUNDLE_FILE_NAME;
args[4] = fileName;
if (locale.length() > 0) {
args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.RESOURCE_BUNDLE_LOCALE;
args[6] = locale;
}
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
ResourceBundle res = (locale.length() == 0) ? ISResourceBundle.getResourceBundle(getAdminSSOToken(), bundleName, (String) null) : ISResourceBundle.getResourceBundle(getAdminSSOToken(), bundleName, locale);
assert (res != null);
exiting("addResourceBundle");
}
use of java.util.ResourceBundle in project OpenAM by OpenRock.
the class ResourceBundleTest method removeResourceBundle.
@Parameters({ "bundle-name", "locale" })
@Test(groups = { "cli-resource-bundle", "remove-res-bundle" }, dependsOnMethods = { "getResourceBundle" })
public void removeResourceBundle(String bundleName, String locale) throws CLIException, SSOException {
entering("removeResourceBundle", null);
String[] args = (locale.length() == 0) ? new String[3] : new String[5];
args[0] = "remove-res-bundle";
args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.RESOURCE_BUNDLE_NAME;
args[2] = bundleName;
if (locale.length() > 0) {
args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.RESOURCE_BUNDLE_LOCALE;
args[4] = locale;
}
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
try {
ResourceBundle res = (locale.length() == 0) ? ISResourceBundle.getResourceBundle(getAdminSSOToken(), bundleName, (String) null) : ISResourceBundle.getResourceBundle(getAdminSSOToken(), bundleName, locale);
assert (res.getLocale() == null);
} catch (MissingResourceException e) {
//Ignored
}
if (!locale.isEmpty()) {
//clean up the default resourcebundle too, after removing the JP version
removeResourceBundle(bundleName, "");
}
exiting("removeResourceBundle");
}
Aggregations