Search in sources :

Example 66 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class AutoCompleterListReceiver method addEntry.

@Override
public void addEntry(String key, String displayKey, String displayText, String iconCssClass) {
    if (key == null) {
        throw new AssertException("Can not add entry with displayText::" + displayText + " with a NULL key!");
    }
    if (isLogDebugEnabled()) {
        logDebug("Add entry with key::" + key + ", displayKey::" + displayKey + ", displayText::" + displayText + ", iconCssClass::" + iconCssClass);
    }
    try {
        JSONObject object = new JSONObject();
        // add key
        object.put("key", key);
        // add displayable key, use key as fallback
        if (showDisplayKey) {
            if (displayKey == null) {
                object.put(DISPLAY_KEY, key);
            } else {
                object.put(DISPLAY_KEY, displayKey);
            }
        }
        // add value to be displayed
        object.put(VALUE, displayText);
        // add optional css class
        if (iconCssClass == null) {
            object.put(CSS_CLASS, CSS_CLASS_EMPTY);
        } else {
            object.put(CSS_CLASS, iconCssClass);
        }
        // JSCON object finished
        list.put(object);
    } catch (JSONException e) {
        // do nothing, only log error to logfile
        logError("Could not add entry with key::" + key + ", displayKey::" + displayKey + ", displayText::" + displayText + ", iconCssClass::" + iconCssClass, e);
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException)

Example 67 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class FactoryControllerCreator method createController.

/**
 * @see org.olat.core.gui.control.creator.ControllerCreator#createController(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl)
 */
public Controller createController(UserRequest lureq, WindowControl lwControl) {
    Exception re = null;
    try {
        Object o = null;
        Class<?> cclazz = Thread.currentThread().getContextClassLoader().loadClass(factoryName);
        try {
            Constructor<?> con = cclazz.getConstructor(ARGCLASSES);
            o = con.newInstance(new Object[] { lureq, lwControl });
        } catch (NoSuchMethodException e) {
        // constructor does not exist with arguments ARGCLASSES => try invoking
        // method without instantiated class (o = null).
        }
        Method method = cclazz.getMethod(factoryMethod, ARGCLASSES);
        Object result = method.invoke(o, new Object[] { lureq, lwControl });
        Controller c = (Controller) result;
        return c;
    } catch (ClassNotFoundException e) {
        re = e;
    } catch (SecurityException e) {
        re = e;
    } catch (NoSuchMethodException e) {
        re = e;
    } catch (IllegalArgumentException e) {
        re = e;
    } catch (IllegalAccessException e) {
        re = e;
    } catch (InvocationTargetException e) {
        re = e;
    } catch (InstantiationException e) {
        re = e;
    } finally {
        if (re != null) {
            throw new AssertException("could not create controller via reflection. factoryName: " + factoryName + " method: " + factoryMethod, re);
        }
    }
    return null;
}
Also used : AssertException(org.olat.core.logging.AssertException) Method(java.lang.reflect.Method) Controller(org.olat.core.gui.control.Controller) AssertException(org.olat.core.logging.AssertException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 68 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class GenericMainController method getContentCtr.

private Controller getContentCtr(Object uobject, UserRequest ureq) {
    Controller contentCtr1Tmp = null;
    if (uobject instanceof ActionExtension) {
        ActionExtension ae = (ActionExtension) uobject;
        contentCtr1Tmp = createController(ae, ureq);
    } else {
        contentCtr1Tmp = handleOwnMenuTreeEvent(uobject, ureq);
    }
    if (contentCtr1Tmp == null) {
        throw new AssertException("Node must either be an ActionExtension or implementation must handle this MenuTreeEvent: " + (uobject == null ? "NULL" : uobject.toString()));
    }
    return contentCtr1Tmp;
}
Also used : AssertException(org.olat.core.logging.AssertException) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController)

Example 69 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class DialogBoxUIFactory method createResourceLockedMessage.

/**
 * create the default info message shown for an unsuccessfully acquired lock - must not be called if lock was successfully acquired!
 * @param ureq
 * @param wControl
 * @param lockEntry must be not null
 * @param i18nLockMsgKey must be not null and valid key in the given translator
 * @param translator must be not null
 * @return DialogController
 */
public static DialogBoxController createResourceLockedMessage(UserRequest ureq, WindowControl wControl, LockResult lockEntry, String i18nLockMsgKey, Translator translator) {
    if (lockEntry.isSuccess()) {
        throw new AssertException("do not create a 'is locked message' if lock was succesfull! concerns lock:" + lockEntry.getOwner());
    }
    String fullName = CoreSpringFactory.getImpl(UserManager.class).getUserDisplayName(lockEntry.getOwner());
    String[] i18nParams = new String[] { StringHelper.escapeHtml(fullName), Formatter.getInstance(ureq.getLocale()).formatTime(new Date(lockEntry.getLockAquiredTime())) };
    String lockMsg = translator.translate(i18nLockMsgKey, i18nParams);
    Translator trans = Util.createPackageTranslator(DialogBoxUIFactory.class, ureq.getLocale());
    List<String> okButton = new ArrayList<String>();
    okButton.add(trans.translate("ok"));
    DialogBoxController ctrl = new DialogBoxController(ureq, wControl, null, lockMsg, okButton);
    ctrl.setCssClass("o_warning");
    return ctrl;
}
Also used : AssertException(org.olat.core.logging.AssertException) Translator(org.olat.core.gui.translator.Translator) UserManager(org.olat.user.UserManager) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 70 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class Renderer method render.

/**
 * used by the renderer, and also by the panel and tabbedpane renderer to delegate rendering
 * @param sb
 * @param source
 * @param args
 */
public void render(StringOutput sb, Component source, String[] args) {
    GlobalSettings gset = getGlobalSettings();
    boolean ajaxon = gset.getAjaxFlags().isIframePostEnabled();
    // wrap with div's so javascript can replace this component by doing a document.getElementById(cid).innerHTML and so on.
    boolean domReplaceable = source.isDomReplaceable();
    boolean useSpan = source.getSpanAsDomReplaceable();
    boolean domReplacementWrapperRequired = source.isDomReplacementWrapperRequired();
    boolean forceDebugDivs = gset.isIdDivsForced();
    if (source.isVisible()) {
        int lev = renderResult.getNestedLevel();
        if (lev > 60)
            throw new AssertException("components were nested more than 60 times, assuming endless loop bug: latest comp name: " + source.getComponentName());
        Translator componentTranslator = source.getTranslator();
        // identifier for dom replacement
        if (domReplaceable && domReplacementWrapperRequired && (ajaxon || forceDebugDivs)) {
            if (useSpan) {
                sb.append("<span id='o_c").append(source.getDispatchID());
            } else {
                sb.append("<div id='o_c").append(source.getDispatchID());
            }
            if (Settings.isDebuging()) {
            // sb.append("' title='").append(source.getComponentName());
            }
            sb.append("'>");
        }
        ComponentRenderer cr = findComponentRenderer(source);
        URLBuilder cubu = urlBuilder.createCopyFor(source);
        renderResult.incNestedLevel();
        // ---- for gui debug mode, direct the rendering to a special componentrenderer
        InterceptHandlerInstance dhi = renderResult.getInterceptHandlerInstance();
        if (dhi != null) {
            cr = dhi.createInterceptComponentRenderer(cr);
        }
        try {
            int preRenderLength = sb.length();
            cr.render(this, sb, source, cubu, componentTranslator, renderResult, args);
            if (preRenderLength == sb.length()) {
                // Add bugfix for IE min-height on empty div problem: min-height does
                // not get applied when div contains an empty comment.
                // Affects IE6, IE7
                sb.append("<!-- empty -->");
            }
            source.setDirty(false);
        } catch (Exception e) {
            // in order to produce a decent error msg, we need to postpone the
            // exception
            renderResult.setRenderExceptionInfo("exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage(), e);
        }
        renderResult.decNestedLevel();
        if (ajaxon && domReplaceable && domReplacementWrapperRequired) {
            if (useSpan) {
                sb.append("</span>");
            } else {
                sb.append("</div>");
            }
        }
    } else {
        // not visible
        if (domReplaceable && (ajaxon || forceDebugDivs)) {
            // browser dom tree
            if (useSpan) {
                sb.append("<span id=\"o_c").append(source.getDispatchID()).append("\"></span>");
            } else {
                // Add bugfix for IE min-height on empty div problem: min-height does
                // not get applied when div contains an empty comment.
                // Affects IE6, IE7
                sb.append("<div id=\"o_c").append(source.getDispatchID()).append("\"><!-- empty --></div>");
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Translator(org.olat.core.gui.translator.Translator) GlobalSettings(org.olat.core.gui.GlobalSettings) InterceptHandlerInstance(org.olat.core.gui.render.intercept.InterceptHandlerInstance) AssertException(org.olat.core.logging.AssertException)

Aggregations

AssertException (org.olat.core.logging.AssertException)364 IOException (java.io.IOException)38 File (java.io.File)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)24 Controller (org.olat.core.gui.control.Controller)22 OLATResourceable (org.olat.core.id.OLATResourceable)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 WindowControl (org.olat.core.gui.control.WindowControl)20 UnsupportedEncodingException (java.io.UnsupportedEncodingException)18 JSONException (org.json.JSONException)18 BusinessGroup (org.olat.group.BusinessGroup)18 JSONObject (org.json.JSONObject)16 UserRequest (org.olat.core.gui.UserRequest)16 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 VFSItem (org.olat.core.util.vfs.VFSItem)16 Date (java.util.Date)14 Properties (java.util.Properties)14 Property (org.olat.properties.Property)14