@Override public void init(FilterConfig config) throws ServletException { // read config m_getMinSize = Integer.parseInt(ObjectUtility.nvl(config.getInitParameter("get_min_size"), "256")); m_postMinSize = Integer.parseInt(ObjectUtility.nvl(config.getInitParameter("post_min_size"), "256")); m_contentTypes = CollectionUtility.hashSet(StringUtility.split(ObjectUtility.nvl(config.getInitParameter("content_types"), CONTENT_TYPES), ",")); }
/** * Converts the space separated CSS class string to a list. */ static List<String> cssClassesAsList(String cssClass) { List<String> cssClasses = new ArrayList<>(); String cssClassesStr = ObjectUtility.nvl(cssClass, ""); cssClassesStr = cssClassesStr.trim(); if (cssClassesStr.length() > 0) { cssClasses = CollectionUtility.arrayList(cssClassesStr.split(" ")); } return cssClasses; } }
/** * @param resp * May be null, since this method can be called during a client-job, when no response is available. In that * case no cookie is written. * @param session * HTTP session * @param theme * <code>null</code> will reset the theme to the configured theme */ public void storeTheme(HttpServletResponse resp, HttpSession session, String theme) { theme = ObjectUtility.nvl(theme, getConfiguredTheme()); if (resp != null) { CookieUtility.addPersistentCookie(resp, THEME_COOKIE_NAME, theme); } session.setAttribute(THEME_SESSION_ATTRIBUTE, theme); }
@Override public void setTiles(List<T> tiles) { tiles = ObjectUtility.nvl(tiles, new ArrayList<>()); Map<IGroup, List<T>> map = new HashMap<>(); for (IGroup group : getGroupsInternal()) { map.put(group, new ArrayList<>()); } for (T tile : tiles) { IGroup group = getOrCreateGroupByTile(tile); map.putIfAbsent(group, new ArrayList<>()); map.get(group).add(tile); } for (Entry<IGroup, List<T>> entry : map.entrySet()) { IGroup group = entry.getKey(); getTileGrid(group).setTiles(entry.getValue()); if (entry.getValue().size() == 0 && !m_staticGroups.contains(group)) { // Delete obsolete groups but never the static ones deleteGroup(group); } } }
private static String getFormDisplayName(IForm f) { return StringUtility.join(" - ", ObjectUtility.nvl(f.getTitle(), f.getClass().getName()), f.getSubTitle()); }
/** * Initializes this {@link IMom} delegate. * <p> * <h3>Warning: risk of deadlocks!</h3> * <p> * This method is called from within a <i>synchronized</i> block inside {@link #getDelegate()}. The implementation * must <b>not</b> call (directly or indirectly) any other methods on {@link AbstractMomDelegate}. Be very cautious * when calling other code. */ protected IMomImplementor initDelegate() throws Exception { final Class<? extends IMomImplementor> implementorClass = ObjectUtility.nvl(getConfiguredImplementor(), NullMomImplementor.class); final IMomImplementor implementor = BEANS.get(implementorClass); if (NullMomImplementor.class.isAssignableFrom(implementorClass)) { LOG.info("+++ Using '{}' for transport '{}'. No messages are published and received.", implementorClass.getSimpleName(), getClass().getSimpleName()); } else { implementor.init(lookupEnvironment()); } return implementor; }
@Override public void setGroups(List<? extends IGroup> groups) { if (CollectionUtility.equalsCollection(getGroupsInternal(), groups, true)) { return; } List<? extends IGroup> existingGroups = ObjectUtility.nvl(getGroupsInternal(), new ArrayList<>()); groups = ObjectUtility.nvl(groups, new ArrayList<>()); // Dispose old groups (only if they are not in the new list) List<IGroup> groupsToDelete = new ArrayList<IGroup>(existingGroups); groupsToDelete.removeAll(groups); deleteGroupsInternal(groupsToDelete); // Initialize new groups // Only initialize when groups are added later, // if they are added while initConfig runs, initGroups() will take care of the initialization which will be called by the container (e.g. GroupsField) List<IGroup> groupsToInsert = new ArrayList<IGroup>(groups); groupsToInsert.removeAll(existingGroups); addGroupsInternal(groupsToInsert); sortInternal(groups); setGroupsInternal(groups); }
protected Cookie createPersistentSessionCookie(SessionCookieConfig config, HttpSession httpSession) { Cookie cookie = new Cookie(ObjectUtility.nvl(config.getName(), "JSESSIONID"), httpSession.getId()); // The cookie must not expire too early so that it does not break the heart beat -> use a big max age. cookie.setMaxAge((int) TimeUnit.DAYS.toSeconds(365)); // 1 year cookie.setComment(config.getComment()); if (config.getDomain() != null) { cookie.setDomain(config.getDomain()); } cookie.setHttpOnly(config.isHttpOnly()); cookie.setPath(config.getPath()); cookie.setSecure(config.isSecure()); return cookie; }
@Override public void setTiles(List<T> tiles) { if (CollectionUtility.equalsCollection(getTilesInternal(), tiles, true)) { return; } List<T> existingTiles = ObjectUtility.nvl(getTilesInternal(), new ArrayList<>()); tiles = ObjectUtility.nvl(tiles, new ArrayList<>()); // Dispose old tiles (only if they are not in the new list) List<T> tilesToDelete = new ArrayList<>(existingTiles); tilesToDelete.removeAll(tiles); deleteTilesInternal(tilesToDelete); deselectTiles(tilesToDelete); // Initialize new tiles // Only initialize when tiles are added later, // if they are added while initConfig runs, initTiles() will take care of the initialization which will be called by the container (e.g. TileField) List<T> tilesToInsert = new ArrayList<>(tiles); tilesToInsert.removeAll(existingTiles); addTilesInternal(tilesToInsert); sortInternal(tiles); setTilesInternal(tiles); m_filteredTilesDirty = true; applyFilters(tilesToInsert); }
/** * Info: instead of reload the current page in the browser, we could build a servlet-filter which determines what * theme the user has _before_ the client-session is created. However the 'reload' will only be performed in the case * where the browser sends a cookie that doesn't match the user-settings which should not happen often. * * @return Whether or not the page must be reloaded by the browser (required when theme changes after client-session * has been initialized) */ protected boolean initUiTheme(HttpServletRequest req, HttpServletResponse resp, HttpSession httpSession) { UiThemeHelper uiThemeUtility = UiThemeHelper.get(); String modelTheme = m_clientSession.getDesktop().getTheme(); String currentTheme = uiThemeUtility.getTheme(req); if (modelTheme == null) { modelTheme = ObjectUtility.nvl(currentTheme, uiThemeUtility.getConfiguredTheme()); m_clientSession.getDesktop().setTheme(currentTheme); } boolean reloadPage = !modelTheme.equals(currentTheme); uiThemeUtility.storeTheme(resp, httpSession, modelTheme); LOG.debug("UI theme model={} current={} reloadPage={}", modelTheme, currentTheme, reloadPage); return reloadPage; }
@Override public Long getSequenceNextval(String sequenceName) { String s = getSequenceNextvalStatement(sequenceName); Object[][] ret = createStatementProcessor(s, null, 0).processSelect(getTransaction(), getStatementCache(), null); if (ret.length == 1) { return NumberUtility.toLong(ObjectUtility.nvl((Number) ret[0][0], 0)); } return 0L; }
protected void handleModelOpenUri(BinaryResource res, IOpenUriAction openUriAction) { String filename = ObjectUtility.nvl(res.getFilename(), "binaryData"); String filenameEncoded = IOUtility.urlEncode(filename); // add another path segment to filename to distinguish between different resources // with the same filename (also makes hash collisions irrelevant). long counter = RESOURCE_COUNTER.getAndIncrement(); filenameEncoded = counter + "/" + filenameEncoded; BinaryResourceHolder holder = new BinaryResourceHolder(res); if (openUriAction == OpenUriAction.DOWNLOAD) { holder.addHttpResponseInterceptor(new DownloadHttpResponseInterceptor(res.getFilename())); } m_downloads.put(filenameEncoded, holder, openUriAction); String downloadUrl = BinaryResourceUrlUtility.createDynamicAdapterResourceUrl(this, filenameEncoded); handleModelOpenUri(downloadUrl, openUriAction); }
@Override public String createHtml(IWizard w) { String html = m_htmlTemplate; String topPart = ""; String bottomPart = ""; StringBuilder listPart = new StringBuilder(); if (w != null) { if (w.getSubTitle() != null) { topPart = HTML.div(w.getSubTitle()).cssClass("infoBox").toHtml(); } if (w.getActiveStep() != null && (w.getActiveStep().getTooltipText() != null || w.getActiveStep().getSubTitle() != null)) { bottomPart = HTML.div(ObjectUtility.nvl(w.getActiveStep().getSubTitle(), w.getActiveStep().getTooltipText())).cssClass("infoBox").toHtml(); } int index = 1; for (IWizardStep<?> step : w.getSteps()) { String s = createHtmlForStep(step, index, (step == w.getActiveStep())); if (StringUtility.hasText(s)) { listPart.append(s); index++; } } } html = html.replace("#FONT_SIZE_UNIT#", "px"); html = html.replace("#TOP#", topPart); html = html.replace("#LIST#", listPart.toString()); html = html.replace("#BOTTOM#", bottomPart); return html; }
setTableStatus(new Status(ObjectUtility.nvl(e.getDisplayMessage(), TEXTS.get("ErrorWhileLoadingData")), IStatus.ERROR)); throw e;
@Override protected void initConfig() { m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent()); m_grid = new SplitBoxGrid(); super.initConfig(); setSplitHorizontal(getConfiguredSplitHorizontal()); setSplitterEnabled(getConfiguredSplitterEnabled()); setSplitterPosition(getConfiguredSplitterPosition()); setMinSplitterPosition(getConfiguredMinSplitterPosition()); setSplitterPositionType(getConfiguredSplitterPositionType()); setCacheSplitterPosition(getConfiguredCacheSplitterPosition()); setCacheSplitterPositionPropertyName(getConfiguredCacheSplitterPositionPropertyName()); if (getConfiguredCollapsibleField() != null) { setCollapsibleField(getFieldByClass(getConfiguredCollapsibleField())); } setFieldCollapsed(getConfiguredFieldCollapsed()); // legacy mode, use deprecated configured key as fallback, this code will be removed in Scout 8.0 setToggleCollapseKeyStroke(ObjectUtility.nvl(getConfiguredToogleCollapseKeyStroke(), getConfiguredCollapseKeyStroke())); setFirstCollapseKeyStroke(getConfiguredFirstCollapseKeyStroke()); setSecondCollapseKeyStroke(getConfiguredSecondCollapseKeyStroke()); setFieldMinimized(getConfiguredFieldMinimized()); }