use of org.apache.commons.lang.text.StrTokenizer in project zm-mailbox by Zimbra.
the class ContextPathBasedThreadPoolBalancerFilter method parse.
protected void parse(String input) throws ServletException {
rulesByContextPath.clear();
for (String str : new StrTokenizer(input, ",").getTokenArray()) {
String[] array = str.split(":");
if (array.length != 2) {
throw new ServletException("Malformed rules: " + input);
}
String key = StringUtils.trimToNull(array[0]);
String value = StringUtils.trimToNull(array[1]);
if (key == null || value == null) {
throw new ServletException("Malformed rules: " + input);
}
Rules rules = Rules.parse(value);
rulesByContextPath.put(key, rules);
}
}
use of org.apache.commons.lang.text.StrTokenizer 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;
}
StrTokenizer tokenizer = new StrTokenizer(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 = Dom4j.readDocument(xml).getRootElement();
loadLicenses(rootElement);
loadConfig(rootElement);
}
Collections.sort(items);
return this;
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class AppPropertiesTest method testEmptyStringSubstitution.
@Test
public void testEmptyStringSubstitution() {
AppProperties appProperties = new AppProperties(new AppComponents("test"));
appProperties.setProperty("refapp.myConfig", "1.xml ${ext.myConfig} 2.xml");
appProperties.setProperty("ext.myConfig", "");
String propValue = appProperties.getProperty("refapp.myConfig");
log.debug("Property value: '" + propValue + "'");
StrTokenizer tokenizer = new StrTokenizer(propValue);
String[] locations = tokenizer.getTokenArray();
Assert.assertArrayEquals(new String[] { "1.xml", "2.xml" }, locations);
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class MenuConfig method init.
protected void init() {
rootItems.clear();
String configName = AppContext.getProperty(MENU_CONFIG_XML_PROP);
StrTokenizer tokenizer = new StrTokenizer(configName);
for (String location : tokenizer.getTokenArray()) {
Resource resource = resources.getResource(location);
if (resource.exists()) {
InputStream stream = null;
try {
stream = resource.getInputStream();
Element rootElement = Dom4j.readDocument(stream).getRootElement();
loadMenuItems(rootElement, null);
} catch (IOException e) {
throw new RuntimeException("Unable to read menu config", e);
} finally {
IOUtils.closeQuietly(stream);
}
} else {
log.warn("Resource {} not found, ignore it", location);
}
}
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class AbstractMessages method searchMessage.
@Nullable
protected String searchMessage(String packs, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
StrTokenizer tokenizer = new StrTokenizer(packs);
// noinspection unchecked
List<String> list = tokenizer.getTokenList();
Collections.reverse(list);
for (String pack : list) {
if (!enterPack(pack, locale, truncatedLocale, passedPacks))
continue;
String msg = searchOnePack(pack, key, locale, truncatedLocale, passedPacks);
if (msg != null)
return msg;
Locale tmpLocale = truncatedLocale;
while (tmpLocale != null) {
tmpLocale = truncateLocale(tmpLocale);
msg = searchOnePack(pack, key, locale, tmpLocale, passedPacks);
if (msg != null)
return msg;
}
}
if (log.isTraceEnabled()) {
String packName = new StrBuilder().appendWithSeparators(list, ",").toString();
log.trace("Resource '" + makeCacheKey(packName, key, locale, locale) + "' not found");
}
return null;
}
Aggregations