use of org.olat.core.gui.translator.PackageTranslator in project OpenOLAT by OpenOLAT.
the class ProjectBrokerCourseNode method informOnDelete.
/**
* @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
* org.olat.course.ICourse)
*/
@Override
public String informOnDelete(Locale locale, ICourse course) {
Translator trans = new PackageTranslator(PACKAGE_PROJECTBROKER, locale);
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
List<Property> list = cpm.listCourseNodeProperties(this, null, null, null);
// properties exist
if (list.size() != 0)
return trans.translate(NLS_WARN_NODEDELETE);
File fDropboxFolder = new File(FolderConfig.getCanonicalRoot() + DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), this));
// Dropbox folder contains files
if (fDropboxFolder.exists() && fDropboxFolder.list().length > 0)
return trans.translate(NLS_WARN_NODEDELETE);
File fReturnboxFolder = new File(FolderConfig.getCanonicalRoot() + ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), this));
// Returnbox folder contains files
if (fReturnboxFolder.exists() && fReturnboxFolder.list().length > 0)
return trans.translate(NLS_WARN_NODEDELETE);
// no data yet.
return null;
}
use of org.olat.core.gui.translator.PackageTranslator in project OpenOLAT by OpenOLAT.
the class ProjectBrokerCourseNode method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller controller;
// Do not allow guests to access tasks
Roles roles = ureq.getUserSession().getRoles();
if (roles.isGuestOnly()) {
Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale());
String title = trans.translate(NLS_GUESTNOACCESS_TITLE);
String message = trans.translate(NLS_GUESTNOACCESS_MESSAGE);
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
} else {
// Add message id to business path if nodemcd is available
if (nodecmd != null) {
try {
Long projectId = Long.valueOf(nodecmd);
BusinessControlFactory bcf = BusinessControlFactory.getInstance();
BusinessControl businessControl = bcf.createFromString("[Project:" + projectId + "]");
wControl = bcf.createBusinessWindowControl(businessControl, wControl);
} catch (NumberFormatException e) {
// ups, nodecmd is not a message, what the heck is it then?
log.warn("Could not create message ID from given nodemcd::" + nodecmd, e);
}
}
controller = ProjectBrokerControllerFactory.createRunController(ureq, wControl, userCourseEnv, this);
}
Controller wrapperCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_projectbroker_icon");
return new NodeRunConstructionResult(wrapperCtrl);
}
use of org.olat.core.gui.translator.PackageTranslator in project OpenOLAT by OpenOLAT.
the class IQSURVCourseNode method informOnDelete.
/**
* @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
* org.olat.course.ICourse)
*/
@Override
public String informOnDelete(Locale locale, ICourse course) {
// Check if there are qtiresults for this questionnaire
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
Long repKey = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true).getKey();
if (QTIResultManager.getInstance().hasResultSets(course.getResourceableId(), this.getIdent(), repKey)) {
return new PackageTranslator(PACKAGE_IQ, locale).translate("info.nodedelete");
}
return null;
}
use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.
the class UserWebService method validateProperty.
private boolean validateProperty(User user, String value, UserPropertyHandler userPropertyHandler, List<ErrorVO> errors, UserManager um, Locale locale) {
ValidationError error = new ValidationError();
if (!StringHelper.containsNonWhitespace(value) && um.isMandatoryUserProperty(PROPERTY_HANDLER_IDENTIFIER, userPropertyHandler)) {
Translator translator = new PackageTranslator("org.olat.core", locale);
String translation = translator.translate("new.form.mandatory");
errors.add(new ErrorVO("org.olat.core:new.form.mandatory:" + userPropertyHandler.getName(), translation));
return false;
}
value = parseUserProperty(value, userPropertyHandler, locale);
if (!userPropertyHandler.isValidValue(user, value, error, locale)) {
String pack = userPropertyHandler.getClass().getPackage().getName();
Translator translator = new PackageTranslator(pack, locale);
String translation = translator.translate(error.getErrorKey(), error.getArgs());
errors.add(new ErrorVO(pack, error.getErrorKey(), translation));
return false;
} else if ((userPropertyHandler.getName().equals(UserConstants.INSTITUTIONALEMAIL) && StringHelper.containsNonWhitespace(value)) || userPropertyHandler.getName().equals(UserConstants.EMAIL)) {
if (!UserManager.getInstance().isEmailAllowed(value, user)) {
String pack = userPropertyHandler.getClass().getPackage().getName();
Translator translator = new PackageTranslator(pack, locale);
String translation = translator.translate("form.name." + userPropertyHandler.getName() + ".error.exists", new String[] { value });
translation += " (" + value + ")";
errors.add(new ErrorVO("org.olat.user.propertyhandlers:new.form.name." + userPropertyHandler.getName() + ".exists", translation));
}
}
return true;
}
use of org.olat.core.gui.translator.PackageTranslator in project openolat by klemens.
the class OperatorManager method getRegisteredAndAlreadyTranslatedOperatorLabels.
public static String[] getRegisteredAndAlreadyTranslatedOperatorLabels(Locale locale, String[] operatorKeys) {
List<String> keys = Arrays.asList(operatorKeys);
Translator t = new PackageTranslator(OperatorManager.class.getPackage().getName(), locale);
String[] tmp = new String[operatorKeys.length];
int i = 0;
for (Operator o : ops) {
if (keys.contains(o.getOperatorKey())) {
tmp[i++] = t.translate(o.getLabelKey());
}
}
return tmp;
}
Aggregations