Search in sources :

Example 21 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class CreditsLoader method load.

public CreditsLoader load() {
    String configProperty = AppContext.getProperty("cuba.creditsConfig");
    if (StringUtils.isBlank(configProperty)) {
        log.info("Property cuba.creditsConfig is empty");
        return this;
    }
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    String[] locations = tokenizer.getTokenArray();
    for (String location : locations) {
        Resources resources = AppBeans.get(Resources.NAME);
        String xml = resources.getResourceAsString(location);
        if (xml == null) {
            log.debug("Resource {} not found, ignore it", location);
            continue;
        }
        Element rootElement = AppBeans.get(Dom4jTools.class).readDocument(xml).getRootElement();
        loadLicenses(rootElement);
        loadConfig(rootElement);
    }
    Collections.sort(items);
    return this;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) Element(org.dom4j.Element) Resources(com.haulmont.cuba.core.global.Resources)

Example 22 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class PortalDispatcherServlet method getContextConfigLocation.

@Override
public String getContextConfigLocation() {
    String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
    if (StringUtils.isBlank(configProperty)) {
        throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
    }
    File baseDir = new File(AppContext.getProperty("cuba.confDir"));
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    String[] tokenArray = tokenizer.getTokenArray();
    StringBuilder locations = new StringBuilder();
    for (String token : tokenArray) {
        String location;
        if (ResourceUtils.isUrl(token)) {
            location = token;
        } else {
            if (token.startsWith("/"))
                token = token.substring(1);
            File file = new File(baseDir, token);
            if (file.exists()) {
                location = file.toURI().toString();
            } else {
                location = "classpath:" + token;
            }
        }
        locations.append(location).append(" ");
    }
    return locations.toString();
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) File(java.io.File)

Example 23 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class CubaDispatcherServlet method getContextConfigLocation.

@Override
public String getContextConfigLocation() {
    String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
    if (StringUtils.isBlank(configProperty)) {
        throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
    }
    File baseDir = new File(AppContext.getProperty("cuba.confDir"));
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    String[] tokenArray = tokenizer.getTokenArray();
    StringBuilder locations = new StringBuilder();
    for (String token : tokenArray) {
        String location;
        if (ResourceUtils.isUrl(token)) {
            location = token;
        } else {
            if (token.startsWith("/"))
                token = token.substring(1);
            File file = new File(baseDir, token);
            if (file.exists()) {
                location = file.toURI().toString();
            } else {
                location = "classpath:" + token;
            }
        }
        locations.append(location).append(" ");
    }
    return locations.toString();
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) File(java.io.File)

Example 24 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class RemotingServlet method getContextConfigLocation.

@Override
public String getContextConfigLocation() {
    String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
    if (StringUtils.isBlank(configProperty)) {
        throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
    }
    File baseDir = new File(AppContext.getProperty("cuba.confDir"));
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    String[] tokenArray = tokenizer.getTokenArray();
    StringBuilder locations = new StringBuilder();
    for (String token : tokenArray) {
        String location;
        if (ResourceUtils.isUrl(token)) {
            location = token;
        } else {
            if (token.startsWith("/"))
                token = token.substring(1);
            File file = new File(baseDir, token);
            if (file.exists()) {
                location = file.toURI().toString();
            } else {
                location = "classpath:" + token;
            }
        }
        locations.append(location).append(" ");
    }
    return locations.toString();
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) File(java.io.File)

Example 25 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class DesktopThemeLoaderImpl method loadStyle.

private DesktopStyle loadStyle(Element element) {
    final String componentsSubTag = "components";
    String styleName = element.attributeValue("name");
    List<Class> components = null;
    if (element.attributeValue("component") != null) {
        String className = element.attributeValue("component");
        try {
            components = Collections.singletonList(Class.forName(className));
        } catch (ClassNotFoundException e) {
            log.error("Unknown component class: " + className);
        }
    } else {
        Element componentsElement = element.element(componentsSubTag);
        if (componentsElement != null) {
            String componentsStr = componentsElement.getTextTrim();
            StringTokenizer tokenizer = new StringTokenizer(componentsStr);
            components = new ArrayList<>();
            for (String className : tokenizer.getTokenArray()) {
                try {
                    components.add(Class.forName(className));
                } catch (ClassNotFoundException e) {
                    log.error("Unknown component class: " + className);
                }
            }
        }
    }
    List<ComponentDecorator> decorators = new ArrayList<>();
    for (Element childElement : element.elements()) {
        if (!componentsSubTag.equals(childElement.getName())) {
            ComponentDecorator decorator = loadDecorator(childElement);
            if (decorator != null) {
                decorators.add(decorator);
            }
        }
    }
    return new DesktopStyle(styleName, decorators, components);
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) ComponentDecorator(com.haulmont.cuba.desktop.theme.ComponentDecorator)

Aggregations

StringTokenizer (org.apache.commons.text.StringTokenizer)43 IOException (java.io.IOException)9 Resource (org.springframework.core.io.Resource)9 ArrayList (java.util.ArrayList)8 InputStream (java.io.InputStream)7 Element (org.dom4j.Element)5 AppContextInitializedEvent (com.haulmont.cuba.core.sys.events.AppContextInitializedEvent)3 File (java.io.File)3 TextStringBuilder (org.apache.commons.text.TextStringBuilder)3 Events (com.haulmont.cuba.core.global.Events)2 Properties (java.util.Properties)2 Nullable (javax.annotation.Nullable)2 Preconditions (com.google.common.base.Preconditions)1 Resources (com.haulmont.cuba.core.global.Resources)1 CubaClassPathXmlApplicationContext (com.haulmont.cuba.core.sys.CubaClassPathXmlApplicationContext)1 DesktopResources (com.haulmont.cuba.desktop.DesktopResources)1 ComponentDecorator (com.haulmont.cuba.desktop.theme.ComponentDecorator)1 Specification (io.github.linuxforhealth.api.Specification)1 Stores (io.jmix.core.Stores)1 Sequence (io.jmix.data.Sequence)1