use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class MetadataBuildSupport method loadFromPersistenceConfig.
protected void loadFromPersistenceConfig(Map<String, List<EntityClassInfo>> packages, String db) {
String persistenceConfig = getPersistenceConfig(db);
if (persistenceConfig == null)
return;
StrTokenizer persistenceFilesTokenizer = new StrTokenizer(persistenceConfig);
for (String fileName : persistenceFilesTokenizer.getTokenArray()) {
Element root = readXml(fileName);
Element puEl = root.element("persistence-unit");
if (puEl == null)
throw new IllegalStateException("File " + fileName + " has no persistence-unit element");
for (Element classEl : Dom4j.elements(puEl, "class")) {
String className = classEl.getText().trim();
boolean included = false;
for (String rootPackage : packages.keySet()) {
if (className.startsWith(rootPackage + ".")) {
List<EntityClassInfo> classNames = packages.get(rootPackage);
if (classNames == null) {
classNames = new ArrayList<>();
packages.put(rootPackage, classNames);
}
classNames.add(new EntityClassInfo(db, className, true));
included = true;
break;
}
}
if (!included)
throw new IllegalStateException("Can not find a model for class " + className + ". The class's package must be inside of some model's root package.");
}
}
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class DesktopThemeImpl method applyStyle.
@Override
public void applyStyle(Object component, String styleNameString, Set<String> state) {
// split string into individual style names
StrTokenizer tokenizer = new StrTokenizer(styleNameString);
String[] styleNames = tokenizer.getTokenArray();
for (String styleName : styleNames) {
applyStyleName(component, state, styleName);
}
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class DesktopThemeLoaderImpl method loadTheme.
@Override
public DesktopTheme loadTheme(String themeName) {
String themeLocations = config.getResourceLocations();
StrTokenizer tokenizer = new StrTokenizer(themeLocations);
String[] locationList = tokenizer.getTokenArray();
List<String> resourceLocationList = new ArrayList<>();
DesktopThemeImpl theme = createTheme(themeName, locationList);
theme.setName(themeName);
for (String location : locationList) {
resourceLocationList.add(getResourcesDir(themeName, location));
String xmlLocation = getConfigFileName(themeName, location);
Resource resource = resources.getResource(xmlLocation);
if (resource.exists()) {
try {
loadThemeFromXml(theme, resource);
} catch (IOException e) {
log.error("Error", e);
}
} else {
log.warn("Resource " + location + " not found, ignore it");
}
}
DesktopResources desktopResources = new DesktopResources(resourceLocationList, resources);
theme.setResources(desktopResources);
return theme;
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class DesktopAppContextLoader method initAppProperties.
protected void initAppProperties() {
AppContext.setProperty(AppConfig.CLIENT_TYPE_PROP, ClientType.DESKTOP.toString());
String appPropertiesConfig = System.getProperty(APP_PROPERTIES_CONFIG_SYS_PROP);
if (StringUtils.isBlank(appPropertiesConfig))
appPropertiesConfig = defaultAppPropertiesConfig;
final Properties properties = new Properties();
StrTokenizer tokenizer = new StrTokenizer(appPropertiesConfig);
for (String str : tokenizer.getTokenArray()) {
InputStream stream = null;
try {
stream = getClass().getResourceAsStream(str);
if (stream != null) {
Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8.name());
properties.load(reader);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(stream);
}
}
for (String arg : args) {
arg = arg.trim();
int pos = arg.indexOf('=');
if (pos > 0) {
String key = arg.substring(0, pos);
String value = arg.substring(pos + 1);
properties.setProperty(key, value);
}
}
for (Object key : properties.keySet()) {
AppContext.setProperty((String) key, properties.getProperty((String) key).trim());
}
List<String> list = new ArrayList<>();
for (String key : AppContext.getPropertyNames()) {
list.add(key + "=" + AppContext.getProperty(key));
}
Collections.sort(list);
log.info(new StrBuilder("AppProperties:\n").appendWithSeparators(list, "\n").toString());
}
use of org.apache.commons.lang.text.StrTokenizer in project iaf by ibissource.
the class MessageStoreListener method getRawMessage.
@Override
public Object getRawMessage(Map threadContext) throws ListenerException {
Object rawMessage = super.getRawMessage(threadContext);
if (rawMessage != null && sessionKeys != null) {
MessageWrapper messageWrapper = (MessageWrapper) rawMessage;
StrTokenizer strTokenizer = StrTokenizer.getCSVInstance().reset(messageWrapper.getText());
messageWrapper.setText((String) strTokenizer.next());
int i = 0;
while (strTokenizer.hasNext()) {
threadContext.put(sessionKeysList.get(i), strTokenizer.next());
i++;
}
}
return rawMessage;
}
Aggregations