Search in sources :

Example 11 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class AppFolderEditWindow method create.

public static FolderEditWindow create(boolean isAppFolder, boolean adding, Folder folder, Presentations presentations, Runnable commitHandler) {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    String className = isAppFolder ? globalConfig.getAppFolderEditWindowClassName() : globalConfig.getFolderEditWindowClassName();
    if (className != null) {
        Class<FolderEditWindow> aClass = ReflectionHelper.getClass(className);
        try {
            Constructor constructor = aClass.getConstructor(boolean.class, Folder.class, Presentations.class, Runnable.class);
            return (FolderEditWindow) constructor.newInstance(adding, folder, presentations, commitHandler);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else
        return isAppFolder ? new AppFolderEditWindow(adding, folder, presentations, commitHandler) : new FolderEditWindow(adding, folder, presentations, commitHandler);
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) Constructor(java.lang.reflect.Constructor) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig)

Example 12 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class CubaHttpFilter method init.

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    try {
        Configuration configuration = AppBeans.get(Configuration.NAME);
        // Fill bypassUrls
        WebConfig webConfig = configuration.getConfig(WebConfig.class);
        bypassUrls.addAll(webConfig.getCubaHttpFilterBypassUrls());
        List<Filter> filters = new ArrayList<>();
        if (configuration.getConfig(WebAuthConfig.class).getExternalAuthentication()) {
            try {
                CubaAuthProvider authProvider = AppBeans.get(CubaAuthProvider.NAME);
                filters.add(authProvider);
            } catch (Exception e) {
                throw new ServletException(e);
            }
        }
        filters.addAll(getHttpRequestFilterBeans());
        setFilters(filters);
        super.init(filterConfig);
        log.debug("CubaHttpFilter initialized");
    } catch (RuntimeException e) {
        log.error("Error initializing CubaHttpFilter", e);
        throw e;
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) HttpRequestFilter(com.haulmont.cuba.web.security.HttpRequestFilter) CompositeFilter(org.springframework.web.filter.CompositeFilter) WebAuthConfig(com.haulmont.cuba.web.auth.WebAuthConfig) ArrayList(java.util.ArrayList) WebConfig(com.haulmont.cuba.web.WebConfig) CubaAuthProvider(com.haulmont.cuba.web.auth.CubaAuthProvider) IOException(java.io.IOException)

Example 13 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class WebWindow method formatTabCaption.

protected String formatTabCaption(final String caption, final String description) {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    WebConfig webConfig = configuration.getConfig(WebConfig.class);
    String tabCaption = formatTabDescription(caption, description);
    int maxLength = webConfig.getMainTabCaptionLength();
    if (tabCaption.length() > maxLength) {
        return tabCaption.substring(0, maxLength) + "...";
    } else {
        return tabCaption;
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) WebConfig(com.haulmont.cuba.web.WebConfig)

Example 14 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class WebAbstractUploadComponent method getActualFileSizeLimit.

protected long getActualFileSizeLimit() {
    final long maxSize;
    if (fileSizeLimit > 0) {
        maxSize = fileSizeLimit;
    } else {
        Configuration configuration = AppBeans.get(Configuration.NAME);
        final long maxUploadSizeMb = configuration.getConfig(ClientConfig.class).getMaxUploadSizeMb();
        maxSize = maxUploadSizeMb * BYTES_IN_MEGABYTE;
    }
    return maxSize;
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 15 with Configuration

use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.

the class WebAbstractUploadComponent method getFileSizeLimitString.

protected String getFileSizeLimitString() {
    String fileSizeLimitString;
    if (fileSizeLimit > 0) {
        if (fileSizeLimit % BYTES_IN_MEGABYTE == 0) {
            fileSizeLimitString = String.valueOf(fileSizeLimit / BYTES_IN_MEGABYTE);
        } else {
            Datatype<Double> doubleDatatype = Datatypes.getNN(Double.class);
            double fileSizeInMb = fileSizeLimit / ((double) BYTES_IN_MEGABYTE);
            fileSizeLimitString = doubleDatatype.format(fileSizeInMb);
        }
    } else {
        Configuration configuration = AppBeans.get(Configuration.NAME);
        fileSizeLimitString = String.valueOf(configuration.getConfig(ClientConfig.class).getMaxUploadSizeMb());
    }
    return fileSizeLimitString;
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Aggregations

Configuration (com.haulmont.cuba.core.global.Configuration)34 ClientConfig (com.haulmont.cuba.client.ClientConfig)13 GlobalConfig (com.haulmont.cuba.core.global.GlobalConfig)9 WebConfig (com.haulmont.cuba.web.WebConfig)7 Messages (com.haulmont.cuba.core.global.Messages)4 File (java.io.File)4 IOException (java.io.IOException)4 DesktopConfig (com.haulmont.cuba.desktop.DesktopConfig)3 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)3 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)3 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)2 FileUploadingAPI (com.haulmont.cuba.gui.upload.FileUploadingAPI)2 AppUI (com.haulmont.cuba.web.AppUI)2 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)2 FileResource (com.vaadin.server.FileResource)2 Resource (com.vaadin.server.Resource)2 com.vaadin.ui (com.vaadin.ui)2 TextAttribute (java.awt.font.TextAttribute)2 FileOutputStream (java.io.FileOutputStream)2