SUPPORT-8438
This commit is contained in:
parent
bf87c0c69b
commit
3d89fb5780
3 changed files with 33 additions and 19 deletions
|
|
@ -1,20 +1,21 @@
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
import org.springframework.web.util.IntrospectorCleanupListener;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
|
||||
import com.hazelcast.internal.util.JsonUtil;
|
||||
import org.jooq.impl.QOM;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
import org.springframework.web.util.IntrospectorCleanupListener;
|
||||
|
||||
/**
|
||||
* This initializer creates root context and registers dispatcher servlet
|
||||
* Spring scans for initializers automatically
|
||||
*/
|
||||
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebAppInitializer.class);
|
||||
|
||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
||||
super.onStartup(servletContext);
|
||||
servletContext.addListener(new IntrospectorCleanupListener());
|
||||
|
|
@ -36,9 +37,11 @@ public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServlet
|
|||
|
||||
@Override
|
||||
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
|
||||
int maxFileSize = Integer.parseInt(System.getenv("ervu.fileupload.max_file_size"));
|
||||
int maxRequestSize = Integer.parseInt(System.getenv("${ervu.fileupload.max_request_size}"));
|
||||
int fileSizeThreshold = Integer.parseInt(System.getenv("${ervu.fileupload.file_size_threshold}"));
|
||||
|
||||
// read from env or assign default values
|
||||
int maxFileSize = parseOrDefault("ERVU_FILE_UPLOAD_MAX_FILE_SIZE", 5242880);
|
||||
int maxRequestSize = parseOrDefault("ERVU_FILE_UPLOAD_MAX_REQUEST_SIZE", 6291456);
|
||||
int fileSizeThreshold = parseOrDefault("ERVU_FILE_UPLOAD_FILE_SIZE_THRESHOLD", 0);
|
||||
|
||||
MultipartConfigElement multipartConfigElement = new MultipartConfigElement(
|
||||
"/tmp",
|
||||
|
|
@ -47,10 +50,24 @@ public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServlet
|
|||
fileSizeThreshold);
|
||||
registration.setMultipartConfig(multipartConfigElement);
|
||||
|
||||
System.out.println("=8=8> MFS : " + multipartConfigElement.getMaxFileSize());
|
||||
System.out.println("=8=8> MRS : " + multipartConfigElement.getMaxRequestSize());
|
||||
System.out.println("=8=8> FST : " + multipartConfigElement.getFileSizeThreshold());
|
||||
logger.info("Max file upload size is set to: " + multipartConfigElement.getMaxFileSize());
|
||||
logger.info("Max file upload request size is set to: " + multipartConfigElement.getMaxRequestSize());
|
||||
logger.info("File size threshold is set to: " + multipartConfigElement.getFileSizeThreshold());
|
||||
|
||||
}
|
||||
|
||||
private int parseOrDefault(String envVar, int defaultVal) {
|
||||
String envVarValue = System.getenv(envVar);
|
||||
if (envVar == null) {
|
||||
logger.info("Environment variable {} is null, using default value: {}", envVar, defaultVal);
|
||||
return defaultVal;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(envVarValue);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.info("Environment variable {} is not an integer, using default value: {}", envVar, defaultVal);
|
||||
return defaultVal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ ERVU_KAFKA_PASSWORD=Blfi9d2OFG
|
|||
ERVU_KAFKA_EXCERPT_REPLY_TOPIC=ervu.lkrp.excerpt.response
|
||||
ERVU_KAFKA_EXCERPT_REQUEST_TOPIC=ervu.lkrp.excerpt.request
|
||||
|
||||
ERVU_FILE_UPLOAD_MAX_FILE_SIZE=5242880
|
||||
ERVU_FILE_UPLOAD_MAX_REQUEST_SIZE=6291456
|
||||
ERVU_FILE_UPLOAD_FILE_SIZE_THRESHOLD=0
|
||||
|
||||
S3_ENDPOINT=http://ervu-minio.k8s.micord.ru:31900
|
||||
S3_ACCESS_KEY=rlTdTvkmSXu9FsLhfecw
|
||||
S3_SECRET_KEY=NUmY0wwRIEyAd98GCKd1cOgJWvLQYAcMMul5Ulu0
|
||||
|
||||
ervu.fileupload.max_file_size=1
|
||||
ervu.fileupload.max_request_size=10
|
||||
ervu.fileupload.file_size_threshold=10
|
||||
|
|
|
|||
|
|
@ -64,9 +64,6 @@
|
|||
<property name="av.kafka.username" value="user1"/>
|
||||
<property name="av.kafka.password" value="Blfi9d2OFG"/>
|
||||
<property name="av.kafka.message.topic.name" value="file-to-upload"/>
|
||||
<property name="ervu.fileupload.max_file_size" value="5242880"/>
|
||||
<property name="ervu.fileupload.max_request_size" value="6291456"/>
|
||||
<property name="ervu.fileupload.file_size_threshold" value="0"/>
|
||||
<property name="esia.scopes" value="fullname, snils, id_doc, birthdate, usr_org, openid"/>
|
||||
<property name="esia.org.scopes" value="org_fullname, org_shortname, org_brhs, org_brhs_ctts, org_brhs_addrs, org_type, org_ogrn, org_inn, org_leg, org_kpp, org_ctts, org_addrs, org_grps, org_emps"/>
|
||||
<property name="esia.org.scope.url" value="http://esia.gosuslugi.ru/"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue