Search in sources :

Example 31 with URLBuilder

use of org.olat.core.gui.render.URLBuilder in project OpenOLAT by OpenOLAT.

the class RemoteLoginformDispatcher method getRedirectToURL.

private String getRedirectToURL(UserSession usess) {
    Window w = Windows.getWindows(usess).getChiefController().getWindow();
    URLBuilder ubu = new URLBuilder("", w.getInstanceId(), String.valueOf(w.getTimestamp()));
    StringOutput sout = new StringOutput(30);
    ubu.buildURI(sout, null, null);
    return WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED + sout.toString();
}
Also used : Window(org.olat.core.gui.components.Window) StringOutput(org.olat.core.gui.render.StringOutput) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 32 with URLBuilder

use of org.olat.core.gui.render.URLBuilder in project openolat by klemens.

the class ExportBinderAsCPResource method renderVelocityContainer.

private String renderVelocityContainer(VelocityContainer mainVC) {
    StringOutput sb = new StringOutput(32000);
    URLBuilder ubu = new URLBuilder("auth", "1", "0");
    Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
    VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
    mainVC.contextPut("r", vrdec);
    renderer.render(sb, mainVC, null);
    return sb.toString();
}
Also used : Renderer(org.olat.core.gui.render.Renderer) RenderResult(org.olat.core.gui.render.RenderResult) StringOutput(org.olat.core.gui.render.StringOutput) URLBuilder(org.olat.core.gui.render.URLBuilder) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator)

Example 33 with URLBuilder

use of org.olat.core.gui.render.URLBuilder in project openolat by klemens.

the class AuthHelper method doLogin.

/**
 * Used by DMZDispatcher to do regular logins and by ShibbolethDispatcher
 * which is somewhat special because logins are handled asynchronuous ->
 * therefore a dedicated dispatcher is needed which also has to have access to
 * the doLogin() method.
 *
 * @param identity
 * @param authProvider
 * @param ureq
 * @return True if success, false otherwise.
 */
public static int doLogin(Identity identity, String authProvider, UserRequest ureq) {
    int initializeStatus = initializeLogin(identity, authProvider, ureq, false);
    if (initializeStatus != LOGIN_OK) {
        // login not successfull
        return initializeStatus;
    }
    // do logging
    ThreadLocalUserActivityLogger.log(OlatLoggingAction.OLAT_LOGIN, AuthHelper.class, LoggingResourceable.wrap(identity));
    // brasato:: fix it
    // successfull login, reregister window
    ChiefController occ;
    if (ureq.getUserSession().getRoles().isGuestOnly()) {
        occ = createGuestHome(ureq);
    } else {
        occ = createAuthHome(ureq);
    }
    Window currentWindow = occ.getWindow();
    currentWindow.setUriPrefix(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED);
    Windows.getWindows(ureq).registerWindow(currentWindow);
    RedirectMediaResource redirect;
    String redirectTo = (String) ureq.getUserSession().getEntry("redirect-bc");
    if (StringHelper.containsNonWhitespace(redirectTo)) {
        String url = WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED + redirectTo;
        redirect = new RedirectMediaResource(url);
    } else {
        // redirect to AuthenticatedDispatcher
        // IMPORTANT: windowID has changed due to re-registering current window -> do not use ureq.getWindowID() to build new URLBuilder.
        URLBuilder ubu = new URLBuilder(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED, currentWindow.getInstanceId(), "1");
        StringOutput sout = new StringOutput(30);
        ubu.buildURI(sout, null, null);
        redirect = new RedirectMediaResource(sout.toString());
    }
    ureq.getDispatchResult().setResultingMediaResource(redirect);
    return LOGIN_OK;
}
Also used : Window(org.olat.core.gui.components.Window) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) StringOutput(org.olat.core.gui.render.StringOutput) ChiefController(org.olat.core.gui.control.ChiefController) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 34 with URLBuilder

use of org.olat.core.gui.render.URLBuilder in project openolat by klemens.

the class InlineTranslationInterceptHandlerController method createInterceptComponentRenderer.

public ComponentRenderer createInterceptComponentRenderer(final ComponentRenderer originalRenderer) {
    return new ComponentRenderer() {

        @Override
        public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
            // ------------- show translator keys
            // we must let the original renderer do its work so that the
            // collecting translator is callbacked.
            // we save the result in a new var since it is too early to
            // append it
            // to the 'stream' right now.
            StringOutput sbOrig = new StringOutput();
            try {
                originalRenderer.render(renderer, sbOrig, source, ubu, translator, renderResult, args);
            } catch (Exception e) {
                String emsg = "exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage();
                sbOrig.append("<span style=\"color:red\">Exception</span><br /><pre>" + emsg + "</pre>");
            }
            String rendered = sbOrig.toString();
            String renderedWithHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(rendered, inlineTranslationURLBuilder, getTranslator());
            sb.append(renderedWithHTMLMarkup);
        }

        /**
         * @see org.olat.core.gui.components.ComponentRenderer#renderHeaderIncludes(org.olat.core.gui.render.Renderer,
         *      org.olat.core.gui.render.StringOutput,
         *      org.olat.core.gui.components.Component,
         *      org.olat.core.gui.render.URLBuilder,
         *      org.olat.core.gui.translator.Translator,
         *      org.olat.core.gui.render.RenderingState)
         */
        @Override
        public void renderHeaderIncludes(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderingState rstate) {
            originalRenderer.renderHeaderIncludes(renderer, sb, source, ubu, translator, rstate);
        }

        /**
         * @see org.olat.core.gui.components.ComponentRenderer#renderBodyOnLoadJSFunctionCall(org.olat.core.gui.render.Renderer,
         *      org.olat.core.gui.render.StringOutput,
         *      org.olat.core.gui.components.Component,
         *      org.olat.core.gui.render.RenderingState)
         */
        @Override
        public void renderBodyOnLoadJSFunctionCall(Renderer renderer, StringOutput sb, Component source, RenderingState rstate) {
            originalRenderer.renderBodyOnLoadJSFunctionCall(renderer, sb, source, rstate);
        }
    };
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Translator(org.olat.core.gui.translator.Translator) Renderer(org.olat.core.gui.render.Renderer) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) RenderResult(org.olat.core.gui.render.RenderResult) RenderingState(org.olat.core.gui.render.RenderingState) StringOutput(org.olat.core.gui.render.StringOutput) DelegatingComponent(org.olat.core.gui.components.delegating.DelegatingComponent) Component(org.olat.core.gui.components.Component) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 35 with URLBuilder

use of org.olat.core.gui.render.URLBuilder in project openolat by klemens.

the class MailContextCellRenderer method render.

@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
    if (val instanceof ContextPair) {
        ContextPair context = (ContextPair) val;
        if (renderer == null) {
            StringHelper.escapeHtml(sb, context.getName());
        } else {
            String contextName = StringHelper.escapeHtml(context.getName());
            Link link = LinkFactory.createLink("bp_" + UUID.randomUUID().toString(), container, listeningController);
            link.setCustomDisplayText(contextName);
            link.setUserObject(context.getBusinessPath());
            URLBuilder ubu = renderer.getUrlBuilder().createCopyFor(link);
            RenderResult renderResult = new RenderResult();
            link.getHTMLRendererSingleton().render(renderer, sb, link, ubu, translator, renderResult, null);
        }
    }
}
Also used : RenderResult(org.olat.core.gui.render.RenderResult) Link(org.olat.core.gui.components.link.Link) ContextPair(org.olat.core.util.mail.ui.MailDataModel.ContextPair) URLBuilder(org.olat.core.gui.render.URLBuilder)

Aggregations

URLBuilder (org.olat.core.gui.render.URLBuilder)36 StringOutput (org.olat.core.gui.render.StringOutput)30 RenderResult (org.olat.core.gui.render.RenderResult)24 Renderer (org.olat.core.gui.render.Renderer)20 IOException (java.io.IOException)10 Translator (org.olat.core.gui.translator.Translator)10 ArrayList (java.util.ArrayList)6 Component (org.olat.core.gui.components.Component)6 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)6 Window (org.olat.core.gui.components.Window)6 Link (org.olat.core.gui.components.link.Link)6 ChiefController (org.olat.core.gui.control.ChiefController)6 RenderingState (org.olat.core.gui.render.RenderingState)6 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)6 GlobalSettings (org.olat.core.gui.GlobalSettings)4 DelegatingComponent (org.olat.core.gui.components.delegating.DelegatingComponent)4 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)4 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)4 Command (org.olat.core.gui.control.winmgr.Command)4 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)4