use of org.codelibs.core.misc.DynamicProperties in project fess by codelibs.
the class ThumbnailGenerator method process.
private static int process(final Options options) {
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
if (StringUtil.isNotBlank(options.propertiesPath)) {
systemProperties.reload(options.propertiesPath);
} else {
try {
final File propFile = ComponentUtil.getSystemHelper().createTempFile("thumbnail_", ".properties");
if (propFile.delete() && logger.isDebugEnabled()) {
logger.debug("Deleted a temp file: {}", propFile.getAbsolutePath());
}
systemProperties.reload(propFile.getAbsolutePath());
propFile.deleteOnExit();
} catch (final Exception e) {
logger.warn("Failed to create system properties file.", e);
}
}
int totalCount = 0;
int count = 1;
final ExecutorService executorService = Executors.newFixedThreadPool(options.numOfThreads);
try {
while (count != 0) {
count = ComponentUtil.getThumbnailManager().generate(executorService, options.cleanup);
totalCount += count;
}
executorService.shutdown();
executorService.awaitTermination(60, TimeUnit.SECONDS);
} catch (final InterruptedException e) {
if (logger.isDebugEnabled()) {
logger.debug("Interrupted.", e);
}
} finally {
executorService.shutdownNow();
}
return totalCount;
}
use of org.codelibs.core.misc.DynamicProperties in project fess by codelibs.
the class QueryHelperTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
queryHelper = new QueryHelper() {
protected QueryParser getQueryParser() {
ExtendableQueryParser queryParser = new ExtendableQueryParser(Constants.DEFAULT_FIELD, new WhitespaceAnalyzer());
queryParser.setAllowLeadingWildcard(true);
queryParser.setDefaultOperator(QueryParser.Operator.AND);
return queryParser;
}
};
File file = File.createTempFile("test", ".properties");
file.deleteOnExit();
FileUtil.writeBytes(file.getAbsolutePath(), "ldap.security.principal=%s@fess.codelibs.local".getBytes("UTF-8"));
DynamicProperties systemProps = new DynamicProperties(file);
ComponentUtil.register(systemProps, "systemProperties");
ComponentUtil.register(new SystemHelper(), "systemHelper");
ComponentUtil.register(new VirtualHostHelper(), "virtualHostHelper");
ComponentUtil.register(new KeyMatchHelper(), "keyMatchHelper");
inject(queryHelper);
queryHelper.init();
}
use of org.codelibs.core.misc.DynamicProperties in project fess by codelibs.
the class ViewHelperTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
propertiesFile = File.createTempFile("test", ".properties");
FileUtil.writeBytes(propertiesFile.getAbsolutePath(), new byte[0]);
propertiesFile.deleteOnExit();
DynamicProperties systemProps = new DynamicProperties(propertiesFile);
ComponentUtil.register(systemProps, "systemProperties");
userAgentHelper = new UserAgentHelper();
ComponentUtil.register(userAgentHelper, "userAgentHelper");
pathMappingHelper = new PathMappingHelper();
pathMappingHelper.init();
ComponentUtil.register(pathMappingHelper, "pathMappingHelper");
FileTypeHelper fileTypeHelper = new FileTypeHelper();
ComponentUtil.register(fileTypeHelper, "fileTypeHelper");
FacetInfo facetInfo = new FacetInfo();
ComponentUtil.register(facetInfo, "facetInfo");
viewHelper = new ViewHelper();
viewHelper.init();
}
use of org.codelibs.core.misc.DynamicProperties in project fess by codelibs.
the class ViewHelper method updateFileProtocol.
protected String updateFileProtocol(String url) {
final int pos = url.indexOf(':', 5);
final boolean isLocalFile = pos > 0 && pos < 12;
final UserAgentType ua = ComponentUtil.getUserAgentHelper().getUserAgentType();
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
switch(ua) {
case IE:
if (isLocalFile) {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.winlocal.ie", "file://"));
} else {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.ie", "file://"));
}
break;
case FIREFOX:
if (isLocalFile) {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.winlocal.firefox", "file://"));
} else {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.firefox", "file://///"));
}
break;
case CHROME:
if (isLocalFile) {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.winlocal.chrome", "file://"));
} else {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.chrome", "file://"));
}
break;
case SAFARI:
if (isLocalFile) {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.winlocal.safari", "file://"));
} else {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.safari", "file:////"));
}
break;
case OPERA:
if (isLocalFile) {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.winlocal.opera", "file://"));
} else {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.opera", "file://"));
}
break;
default:
if (isLocalFile) {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.winlocal.other", "file://"));
} else {
url = url.replaceFirst("file:/+", systemProperties.getProperty("file.protocol.other", "file://"));
}
break;
}
return url;
}
use of org.codelibs.core.misc.DynamicProperties in project fess by codelibs.
the class AdminSysteminfoAction method getBugReportItems.
public static List<Map<String, String>> getBugReportItems() {
final List<Map<String, String>> itemList = new ArrayList<>();
for (final String label : bugReportLabels) {
itemList.add(createPropItem(label));
}
final DynamicProperties systemProperties = ComponentUtil.getSystemProperties();
for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
if (isBugReportTarget(entry.getKey())) {
itemList.add(createItem(entry.getKey(), entry.getValue()));
}
}
return itemList;
}
Aggregations