use of java.util.ResourceBundle in project OpenClinica by OpenClinica.
the class DiscrepancyNoteOutputServlet method makeResolutionStatusDecoder.
private Map<String, String> makeResolutionStatusDecoder() {
Map<String, String> decoder = new HashMap<String, String>();
ResourceBundle reterm = ResourceBundleProvider.getTermsBundle();
for (ResolutionStatus status : ResolutionStatus.list) {
decoder.put(status.getName(), Integer.toString(status.getId()));
}
decoder.put(reterm.getString("New_and_Updated"), "1,2");
return decoder;
}
use of java.util.ResourceBundle in project OpenClinica by OpenClinica.
the class OnChangeSheetValidator method isValidInstantOnChangeItemPair.
private boolean isValidInstantOnChangeItemPair(OnChangeSheetValidationCell onChangeSheetValidationCell) {
SheetCell cell = onChangeSheetValidationCell.getSheetValidationCell().getSheetArgumentCell().getSheetCell();
ResourceBundle resPageMsg = sheetErrors.getResPageMsg();
Map<String, String> allItems = sheetValidationContainer.getAllItems();
if (cell.getColValue() != null && cell.getColValue().length() > 0 && allItems.containsKey(onChangeSheetValidationCell.getOriName())) {
if (sheetValidationContainer.inSameSection(cell.getRowName(), onChangeSheetValidationCell.getOriName())) {
if (isValidInstantOnChangeGroupPair(onChangeSheetValidationCell.getOriName(), cell.getRowName())) {
return true;
} else {
StringBuffer s = new StringBuffer(onChangeSheetValidationCell.getOriName());
s.append(" ");
s.append(resPageMsg.getString("and"));
s.append(" ");
s.append(cell.getRowName());
s.append(" ");
s.append(resPageMsg.getString(OnChangeSheetValidationType.SHOULD_IN_SAME_REPEATING_GROUP.getDescription()));
StringBuffer message = sheetErrors.errorMessage(resPageMsg.getString(cell.getColTitle()), s.toString(), resPageMsg.getString(cell.getForWhich()));
sheetErrors.addError(cell.getRowNum(), message);
sheetErrors.putHtmlError(cell.getSheetNum(), cell.getRowNum(), 6, resPageMsg.getString("INVALID_FIELD"));
}
} else {
StringBuffer s = new StringBuffer(cell.getRowName());
s.append(", ");
s.append(onChangeSheetValidationCell.getOriName());
s.append(" ");
s.append(resPageMsg.getString(OnChangeSheetValidationType.SHOULD_IN_SAME_SECTION.getDescription()));
StringBuffer message = sheetErrors.errorMessage(resPageMsg.getString(cell.getColTitle()), s.toString(), resPageMsg.getString(cell.getForWhich()));
sheetErrors.addError(cell.getRowNum(), message);
sheetErrors.putHtmlError(cell.getSheetNum(), cell.getRowNum(), 5, resPageMsg.getString("INVALID_FIELD"));
}
} else {
StringBuffer s = new StringBuffer(onChangeSheetValidationCell.getOriName());
s.append(" ");
s.append(resPageMsg.getString(SheetValidationType.ITEM_NAME_SHOULD_PROVIDED.getDescription()));
StringBuffer message = sheetErrors.errorMessage(resPageMsg.getString(cell.getColTitle()), s.toString(), resPageMsg.getString(cell.getForWhich()));
sheetErrors.addError(cell.getRowNum(), message);
if (!sheetErrors.htmlErrors.containsKey(sheetErrors.htmlErrorKey(cell.getSheetNum(), cell.getRowNum(), cell.getColNum())))
sheetErrors.putHtmlError(cell.getSheetNum(), cell.getRowNum(), cell.getColNum(), resPageMsg.getString("INVALID_FIELD"));
}
return sheetErrors.getErrors().size() == 0;
}
use of java.util.ResourceBundle in project OpenClinica by OpenClinica.
the class ResetPasswordServlet method processRequest.
/**
* Tasks include:
* <ol>
* <li>Validation:
* <ol>
* <li>1. old password match database record
* <li>2. new password is follows requirements
* <li>4. two times entered passwords are same
* <li>5. all required fields are filled
* </ol>
* <li>Update ub - UserAccountBean - in session and database
* </ol>
*/
@Override
public void processRequest() throws Exception {
logger.info("Change expired password");
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
Validator v = new Validator(request);
errors.clear();
FormProcessor fp = new FormProcessor(request);
String mustChangePwd = request.getParameter("mustChangePwd");
String newPwd = fp.getString("passwd").trim();
String passwdChallengeQ = fp.getString("passwdChallengeQ");
String passwdChallengeA = fp.getString("passwdChallengeA");
if ("yes".equalsIgnoreCase(mustChangePwd)) {
addPageMessage(respage.getString("your_password_has_expired_must_change"));
} else {
addPageMessage(respage.getString("password_expired") + " " + respage.getString("if_you_do_not_want_change_leave_blank"));
}
request.setAttribute("mustChangePass", mustChangePwd);
String oldPwd = fp.getString("oldPasswd").trim();
// user bean from web
UserAccountBean ubForm = new UserAccountBean();
// form
ubForm.setPasswd(oldPwd);
ubForm.setPasswdChallengeQuestion(passwdChallengeQ);
ubForm.setPasswdChallengeAnswer(passwdChallengeA);
request.setAttribute("userBean1", ubForm);
SecurityManager sm = ((SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager"));
if (!sm.isPasswordValid(ub.getPasswd(), oldPwd, getUserDetails())) {
Validator.addError(errors, "oldPasswd", resexception.getString("wrong_old_password"));
request.setAttribute("formMessages", errors);
forwardPage(Page.RESET_PASSWORD);
} else {
if (mustChangePwd.equalsIgnoreCase("yes")) {
v.addValidation("passwd", Validator.NO_BLANKS);
v.addValidation("passwd1", Validator.NO_BLANKS);
v.addValidation("passwdChallengeQ", Validator.NO_BLANKS);
v.addValidation("passwdChallengeA", Validator.NO_BLANKS);
v.addValidation("passwd", Validator.CHECK_DIFFERENT, "oldPasswd");
}
String newDigestPass = sm.encrytPassword(newPwd, getUserDetails());
List<String> pwdErrors = new ArrayList<String>();
if (!StringUtils.isEmpty(newPwd)) {
v.addValidation("passwd", Validator.IS_A_PASSWORD);
v.addValidation("passwd1", Validator.CHECK_SAME, "passwd");
ConfigurationDao configurationDao = SpringServletAccess.getApplicationContext(context).getBean(ConfigurationDao.class);
PasswordRequirementsDao passwordRequirementsDao = new PasswordRequirementsDao(configurationDao);
Locale locale = LocaleResolver.getLocale(request);
ResourceBundle resexception = ResourceBundleProvider.getExceptionsBundle(locale);
pwdErrors = PasswordValidator.validatePassword(passwordRequirementsDao, udao, ub.getId(), newPwd, newDigestPass, resexception);
}
errors = v.validate();
for (String err : pwdErrors) {
v.addError(errors, "passwd", err);
}
if (!errors.isEmpty()) {
logger.info("ResetPassword page has validation errors");
request.setAttribute("formMessages", errors);
forwardPage(Page.RESET_PASSWORD);
} else {
logger.info("ResetPassword page has no errors");
if (!StringUtils.isBlank(newPwd)) {
ub.setPasswd(newDigestPass);
ub.setPasswdTimestamp(new Date());
} else if ("no".equalsIgnoreCase(mustChangePwd)) {
ub.setPasswdTimestamp(new Date());
}
ub.setOwner(ub);
// when update ub, updator id is required
ub.setUpdater(ub);
ub.setPasswdChallengeQuestion(passwdChallengeQ);
ub.setPasswdChallengeAnswer(passwdChallengeA);
udao.update(ub);
ArrayList<String> pageMessages = new ArrayList<String>();
request.setAttribute(PAGE_MESSAGE, pageMessages);
addPageMessage(respage.getString("your_expired_password_reset_successfully"));
ub.incNumVisitsToMainMenu();
forwardPage(Page.MENU_SERVLET);
}
}
}
use of java.util.ResourceBundle in project intellij-community by JetBrains.
the class PyBundle method getBundle.
// Cached loading
private static ResourceBundle getBundle() {
ResourceBundle bundle = SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<>(bundle);
}
return bundle;
}
use of java.util.ResourceBundle in project intellij-community by JetBrains.
the class DomBundle method getBundle.
private static ResourceBundle getBundle() {
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
ourBundle = new SoftReference<>(bundle);
}
return bundle;
}
Aggregations