mirror of
https://github.com/sismics/docs.git
synced 2025-12-14 02:06:25 +00:00
upgrade to java 11 + upgrade libraries
This commit is contained in:
@@ -95,7 +95,6 @@
|
||||
<dependency>
|
||||
<groupId>at.favre.lib</groupId>
|
||||
<artifactId>bcrypt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -86,7 +86,7 @@ public class WebhookAsyncListener {
|
||||
}
|
||||
});
|
||||
|
||||
RequestBody body = RequestBody.create(JSON, "{\"event\": \"" + event.name() + "\", \"id\": \"" + id + "\"}");
|
||||
RequestBody body = RequestBody.create("{\"event\": \"" + event.name() + "\", \"id\": \"" + id + "\"}", JSON);
|
||||
|
||||
for (String webhookUrl : webhookUrlList) {
|
||||
Request request = new Request.Builder()
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AppContext {
|
||||
List<Class<? extends IndexingHandler>> indexingHandlerList = Lists.newArrayList(
|
||||
new ClasspathScanner<IndexingHandler>().findClasses(IndexingHandler.class, "com.sismics.docs.core.util.indexing"));
|
||||
for (Class<? extends IndexingHandler> handlerClass : indexingHandlerList) {
|
||||
IndexingHandler handler = handlerClass.newInstance();
|
||||
IndexingHandler handler = handlerClass.getDeclaredConstructor().newInstance();
|
||||
if (handler.accept()) {
|
||||
indexingHandler = handler;
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class AuthenticationUtil {
|
||||
|
||||
.map(clazz -> {
|
||||
try {
|
||||
return clazz.newInstance();
|
||||
return clazz.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.sismics.docs.core.model.jpa.Config;
|
||||
import com.sismics.docs.core.model.jpa.User;
|
||||
import com.sismics.docs.core.util.ConfigUtil;
|
||||
import com.sismics.util.ClasspathScanner;
|
||||
import org.apache.commons.pool.impl.GenericObjectPool;
|
||||
import org.apache.directory.api.ldap.model.cursor.EntryCursor;
|
||||
import org.apache.directory.api.ldap.model.entry.Attribute;
|
||||
import org.apache.directory.api.ldap.model.entry.Entry;
|
||||
@@ -71,10 +70,7 @@ public class LdapAuthenticationHandler implements AuthenticationHandler {
|
||||
config.setCredentials(ConfigUtil.getConfigStringValue(ConfigType.LDAP_ADMIN_PASSWORD));
|
||||
|
||||
DefaultLdapConnectionFactory factory = new DefaultLdapConnectionFactory(config);
|
||||
GenericObjectPool.Config poolConfig = new GenericObjectPool.Config();
|
||||
poolConfig.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
|
||||
poolConfig.maxWait = 500;
|
||||
pool = new LdapConnectionPool(new ValidatingPoolableLdapConnectionFactory(factory), poolConfig);
|
||||
pool = new LdapConnectionPool(new ValidatingPoolableLdapConnectionFactory(factory), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +110,7 @@ public class LdapAuthenticationHandler implements AuthenticationHandler {
|
||||
if (mailAttribute == null || mailAttribute.get() == null) {
|
||||
user.setEmail(ConfigUtil.getConfigStringValue(ConfigType.LDAP_DEFAULT_EMAIL));
|
||||
} else {
|
||||
Value<?> value = mailAttribute.get();
|
||||
Value value = mailAttribute.get();
|
||||
user.setEmail(value.getString());
|
||||
}
|
||||
user.setStorageQuota(ConfigUtil.getConfigLongValue(ConfigType.LDAP_DEFAULT_STORAGE));
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sismics.docs.core.util.format;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sismics.util.ClasspathScanner;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,12 +27,12 @@ public class FormatHandlerUtil {
|
||||
public static FormatHandler find(String mimeType) {
|
||||
try {
|
||||
for (Class<? extends FormatHandler> formatHandlerClass : FORMAT_HANDLERS) {
|
||||
FormatHandler formatHandler = formatHandlerClass.newInstance();
|
||||
FormatHandler formatHandler = formatHandlerClass.getDeclaredConstructor().newInstance();
|
||||
if (formatHandler.accept(mimeType)) {
|
||||
return formatHandler;
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||
import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
|
||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
||||
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
|
||||
import org.apache.poi.sl.extractor.SlideShowExtractor;
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlide;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class PptxFormatHandler implements FormatHandler {
|
||||
@Override
|
||||
public String extractContent(String language, Path file) throws Exception {
|
||||
XMLSlideShow pptx = loadPPtxFile(file);
|
||||
return new XSLFPowerPointExtractor(pptx).getText();
|
||||
return new SlideShowExtractor<>(pptx).getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,9 +37,9 @@ import org.apache.lucene.search.spell.LuceneDictionary;
|
||||
import org.apache.lucene.search.suggest.Lookup;
|
||||
import org.apache.lucene.search.suggest.analyzing.FuzzySuggester;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.NIOFSDirectory;
|
||||
import org.apache.lucene.store.NoLockFactory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.store.SimpleFSDirectory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -116,7 +116,7 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
} else if (luceneStorage.equals("FILE")) {
|
||||
Path luceneDirectory = DirectoryUtil.getLuceneDirectory();
|
||||
log.info("Using file Lucene storage: {}", luceneDirectory);
|
||||
directory = new SimpleFSDirectory(luceneDirectory, NoLockFactory.INSTANCE);
|
||||
directory = new NIOFSDirectory(luceneDirectory, NoLockFactory.INSTANCE);
|
||||
}
|
||||
|
||||
// Create an index writer
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sismics.util;
|
||||
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.jsoup.internal.StringUtil;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.nodes.Node;
|
||||
import org.jsoup.nodes.TextNode;
|
||||
@@ -28,7 +28,7 @@ public class HtmlToPlainText {
|
||||
}
|
||||
|
||||
// the formatting rules, implemented in a breadth-first DOM traverse
|
||||
private class FormattingVisitor implements NodeVisitor {
|
||||
static private class FormattingVisitor implements NodeVisitor {
|
||||
private static final int maxWidth = 80;
|
||||
private int width = 0;
|
||||
private StringBuilder accum = new StringBuilder(); // holds the accumulated text
|
||||
@@ -64,7 +64,7 @@ public class HtmlToPlainText {
|
||||
return; // don't accumulate long runs of empty spaces
|
||||
|
||||
if (text.length() + width > maxWidth) { // won't fit, needs to wrap
|
||||
String words[] = text.split("\\s+");
|
||||
String[] words = text.split("\\s+");
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
String word = words[i];
|
||||
boolean last = i == words.length - 1;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.sismics.util.jpa;
|
||||
|
||||
import com.sismics.docs.core.util.DirectoryUtil;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.slf4j.Logger;
|
||||
@@ -34,7 +33,6 @@ public final class EMF {
|
||||
try {
|
||||
properties = getEntityManagerProperties();
|
||||
|
||||
Environment.verifyProperties(properties);
|
||||
ConfigurationHelper.resolvePlaceHolders(properties);
|
||||
ServiceRegistry reg = new StandardServiceRegistryBuilder().applySettings(properties).build();
|
||||
|
||||
|
||||
@@ -137,7 +137,6 @@ public class TestFileUtil {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
PdfUtil.convertToPdf(documentDto, Lists.newArrayList(file0, file1, file2, file3, file4, file5), true, true, 10, outputStream);
|
||||
Assert.assertTrue(outputStream.toByteArray().length > 0);
|
||||
com.google.common.io.Files.write(outputStream.toByteArray(), new java.io.File("C:\\Users\\Jendib\\Downloads\\test.pdf"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user