use of org.olat.core.gui.control.ChiefController in project openolat by klemens.
the class LayoutMain3ColsController method setAsFullscreen.
public void setAsFullscreen(UserRequest ureq) {
ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
if (cc != null) {
thebaseChief = cc;
thebaseChief.getScreenMode().setMode(Mode.full);
} else {
Windows.getWindows(ureq).setFullScreen(Boolean.TRUE);
}
fullScreen = true;
}
use of org.olat.core.gui.control.ChiefController in project openolat by klemens.
the class IsAssessmentModeFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
/*
* expression check only if cev != null
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
// return a valid value to continue with condition evaluation test
return defaultValue();
}
WindowControl wControl = getUserCourseEnv().getWindowControl();
if (wControl == null) {
return ConditionInterpreter.INT_FALSE;
}
ChiefController chiefController = wControl.getWindowBackOffice().getChiefController();
if (chiefController == null) {
return ConditionInterpreter.INT_FALSE;
}
OLATResourceable lockedResource = chiefController.getLockResource();
if (lockedResource == null) {
return ConditionInterpreter.INT_FALSE;
}
Long resourceableId = getUserCourseEnv().getCourseEnvironment().getCourseResourceableId();
if (lockedResource.getResourceableId().equals(resourceableId)) {
RepositoryEntry entry = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseEntry();
AssessmentModeManager assessmentModeMgr = CoreSpringFactory.getImpl(AssessmentModeManager.class);
boolean inAssessment = assessmentModeMgr.isInAssessmentMode(entry, new Date());
return inAssessment ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
} else {
return ConditionInterpreter.INT_FALSE;
}
}
use of org.olat.core.gui.control.ChiefController in project openolat by klemens.
the class QTI21AssessmentMainLayoutController method setAsFullscreen.
public void setAsFullscreen(UserRequest ureq) {
ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
if (cc != null) {
thebaseChief = cc;
thebaseChief.getScreenMode().setMode(Mode.full);
} else {
Windows.getWindows(ureq).setFullScreen(Boolean.TRUE);
}
fullScreen = true;
}
use of org.olat.core.gui.control.ChiefController in project openolat by klemens.
the class ValidatingVisitor method doDispatchToComponent.
/**
* @param ureq
* @return true if the event was indeed dispatched to the component, false
* otherwise (reasons: no component found with given id, or component
* disabled)
*/
private DispatchResult doDispatchToComponent(UserRequest ureq, StringBuilder debugMsg) {
String s_compID = ureq.getComponentID();
if (s_compID == null) {
return NO_DISPATCHRESULT;
}
List<Component> foundPath = new ArrayList<Component>(10);
// OLAT-1973
Component target = ComponentHelper.findDescendantOrSelfByID(getContentPane(), s_compID, foundPath);
if (target == null) {
// there was a component id given, but no matching target could be found
fireEvent(ureq, COMPONENTNOTFOUND);
return NO_DISPATCHRESULT;
// do not dispatch; which means just rerender later; good if
// the
// gui tree was changed by another thread in the meantime.
// do not throw an exception here, because this can happen if the gui
// tree was changed by another thread in the meantime
}
if (!target.isVisible()) {
throw new OLATRuntimeException(Window.class, "target with name: '" + target.getComponentName() + "', was invisible, but called to dispatch", null);
}
boolean toDispatch = true;
boolean incTimestamp = false;
for (Iterator<Component> iter = foundPath.iterator(); iter.hasNext(); ) {
Component curComp = iter.next();
if (!curComp.isEnabled()) {
toDispatch = false;
break;
}
}
if (toDispatch) {
latestDispatchComponentInfo = target.getComponentName() + " :" + target.getExtendedDebugInfo();
latestDispatchedComp = target;
// dispatch
wbackofficeImpl.fireCycleEvent(Window.ABOUT_TO_DISPATCH);
target.dispatchRequest(ureq);
List<Component> ancestors = ComponentHelper.findAncestorsOrSelfByID(getContentPane(), target);
for (Component ancestor : ancestors) {
incTimestamp |= ancestor.isSilentlyDynamicalCmp();
}
// after dispatching, commit (docu)
DBFactory.getInstance().commit();
// add the new URL to the browser history, but not if the klick resulted in a new browser window (a href .. target=...) or in a download (excel or such)
wbackofficeImpl.fireCycleEvent(END_OF_DISPATCH_CYCLE);
// if loglevel is set accordingly, collect anonymous controller usage statistics.
if (debugMsg != null) {
appendDispatchDebugInfos(target, debugMsg);
} else {
// no debug level, consume the left over event (for minor memory reasons)
target.getAndClearLatestFiredEvent();
}
// we do not want to keep a reference which could be old.
// in case we do not reach the next line because of an exception in dispatch(), we clear the value in the exceptionwindowcontroller's error handling
latestDispatchedComp = null;
}
ChiefController chief = wbackofficeImpl.getChiefController();
boolean reload = chief == null ? false : chief.wishReload(ureq, true);
return new DispatchResult(toDispatch, incTimestamp, reload);
}
use of org.olat.core.gui.control.ChiefController in project openolat by klemens.
the class RemoteLoginformDispatcher method execute.
/**
* Tries to login the user with the parameters from the POST request and
* redirects to the home screen in case of success. In case of failure,
* redirects to the login screen.
*
* @param request
* @param response
* @param uriPrefix
*/
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
UserRequest ureq = null;
try {
String uriPrefix = DispatcherModule.getLegacyUriPrefix(request);
ureq = new UserRequestImpl(uriPrefix, request, response);
if (!request.getMethod().equals(METHOD_POST)) {
log.warn("Wrong HTTP method, only POST allowed, but current method::" + request.getMethod());
DispatcherModule.redirectToDefaultDispatcher(response);
return;
}
String userName = ureq.getParameter(PARAM_USERNAME);
if (!StringHelper.containsNonWhitespace(userName)) {
log.warn("Missing username parameter, use '" + PARAM_USERNAME + "' to submit the login name");
DispatcherModule.redirectToDefaultDispatcher(response);
return;
}
String pwd = ureq.getParameter(PARAM_PASSWORD);
if (!StringHelper.containsNonWhitespace(pwd)) {
log.warn("Missing password parameter, use '" + PARAM_PASSWORD + "' to submit the password");
DispatcherModule.redirectToDefaultDispatcher(response);
return;
}
// Authenticate user
OLATAuthManager olatAuthenticationSpi = CoreSpringFactory.getImpl(OLATAuthManager.class);
Identity identity = olatAuthenticationSpi.authenticate(null, userName, pwd);
if (identity == null) {
log.info("Could not authenticate user '" + userName + "', wrong password or user name");
// redirect to OLAT loginscreen, add error parameter so that the loginform can mark itself as errorfull
String loginUrl = WebappHelper.getServletContextPath() + DispatcherModule.getPathDefault() + "?" + OLATAuthenticationController.PARAM_LOGINERROR + "=true";
DispatcherModule.redirectTo(response, loginUrl);
return;
}
UserSession usess = ureq.getUserSession();
// re-init the activity logger to pass the user session and identity
ThreadLocalUserActivityLoggerInstaller.initUserActivityLogger(request);
// sync over the UserSession Instance to prevent double logins
synchronized (usess) {
// Login user, set up everything
int loginStatus = AuthHelper.doLogin(identity, BaseSecurityModule.getDefaultAuthProviderIdentifier(), ureq);
if (loginStatus == AuthHelper.LOGIN_OK) {
// redirect to authenticated environment
UserDeletionManager.getInstance().setIdentityAsActiv(identity);
final String origUri = request.getRequestURI();
String restPart = origUri.substring(uriPrefix.length());
if (request.getParameter("redirect") != null) {
// redirect parameter like: /olat/url/RepositoryEntry/917504/CourseNode/81254724902921
String redirect = request.getParameter("redirect");
DispatcherModule.redirectTo(response, redirect);
} else if (StringHelper.containsNonWhitespace(restPart)) {
// redirect like: http://www.frentix.com/olat/remotelogin/RepositoryEntry/917504/CourseNode/81254724902921
try {
restPart = URLDecoder.decode(restPart, "UTF8");
} catch (UnsupportedEncodingException e) {
log.error("Unsupported encoding", e);
}
String[] split = restPart.split("/");
assert (split.length % 2 == 0);
String businessPath = "";
for (int i = 0; i < split.length; i = i + 2) {
String key = split[i];
if (key != null && key.startsWith("path=")) {
key = key.replace("~~", "/");
}
String value = split[i + 1];
businessPath += "[" + key + ":" + value + "]";
}
// UserSession usess = UserSession.getUserSession(request);
usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_BUSINESSPATH, businessPath);
String url = getRedirectToURL(usess);
DispatcherModule.redirectTo(response, url);
} else {
// redirect
ServletUtil.serveResource(request, response, ureq.getDispatchResult().getResultingMediaResource());
}
} else if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
DispatcherModule.redirectToServiceNotAvailable(response);
} else {
// error, redirect to login screen
DispatcherModule.redirectToDefaultDispatcher(response);
}
}
} catch (Throwable th) {
try {
ChiefController msgcc = MsgFactory.createMessageChiefController(ureq, th);
// the controller's window must be failsafe also
msgcc.getWindow().dispatchRequest(ureq, true);
// do not dispatch (render only), since this is a new Window created as
// a result of another window's click.
} catch (Throwable t) {
log.error("Sorry, can't handle this remote login request....", t);
}
}
}
Aggregations