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;
}
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();
}
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();
}
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();
}
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);
}
Aggregations