use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class CubaRestApiServlet 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"));
StrTokenizer tokenizer = new StrTokenizer(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.lang.text.StrTokenizer in project cuba by cuba-platform.
the class RestServicePermissions method init.
protected void init() {
String configName = AppContext.getProperty(CUBA_REST_SERVICES_CONFIG_PROP_NAME);
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();
loadConfig(Dom4j.readDocument(stream).getRootElement());
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(stream);
}
} else {
log.warn("Resource " + location + " not found, ignore it");
}
}
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class RestQueriesConfiguration method init.
protected void init() {
String configName = AppContext.getProperty(CUBA_REST_QUERIES_CONFIG_PROP_NAME);
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();
loadConfig(Dom4j.readDocument(stream).getRootElement());
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(stream);
}
} else {
log.warn("Resource " + location + " not found, ignore it");
}
}
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class RestServicesConfiguration method init.
protected void init() {
String configName = AppContext.getProperty(CUBA_REST_SERVICES_CONFIG_PROP_NAME);
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();
loadConfig(Dom4j.readDocument(stream).getRootElement());
} catch (IOException e) {
throw new RuntimeException("Error on parsing rest services config", e);
} finally {
IOUtils.closeQuietly(stream);
}
} else {
log.warn("Resource " + location + " not found, ignore it");
}
}
}
use of org.apache.commons.lang.text.StrTokenizer in project cuba by cuba-platform.
the class CubaIdpServlet 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"));
StrTokenizer tokenizer = new StrTokenizer(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();
}
Aggregations