- Improve logging configurations.

- Fix the "AssignmentResponse.toString()" method.
- Update SpringBoot to v.2.5.6
- Code cleanup.
This commit is contained in:
Lampros Smyrnaios 2021-11-04 11:57:19 +02:00
parent 0540820817
commit 0d47c33a08
7 changed files with 29 additions and 28 deletions

View File

@ -1,17 +1,9 @@
buildscript {
ext {
springBootVersion = "2.5.4"
springSecurityVersion = "5.5.2"
}
}
plugins {
id 'org.springframework.boot' version '2.5.4'
id 'org.springframework.boot' version '2.5.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'eu.openaire.urls_controller'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
@ -21,18 +13,24 @@ repositories {
}
dependencies {
runtimeOnly "org.springframework.boot:spring-boot-devtools:${springBootVersion}"
runtimeOnly "org.springframework.boot:spring-boot-devtools"
implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
implementation("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}")
implementation "org.springframework.boot:spring-boot-starter-web"
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-jdbc")
implementation("org.springframework.boot:spring-boot-configuration-processor")
implementation("org.springframework.security:spring-security-core")
implementation("org.springframework.security:spring-security-web")
implementation("org.springframework.security:spring-security-config")
implementation("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}")
implementation("org.springframework.security:spring-security-core:${springSecurityVersion}")
implementation("org.springframework.security:spring-security-web:${springSecurityVersion}")
implementation("org.springframework.security:spring-security-config:${springSecurityVersion}")
//implementation("io.jsonwebtoken:jjwt:0.9.1") // Use this in case we use auth-tokens later on.
// Enable the validation annotations.
//implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
implementation "org.projectlombok:lombok:1.18.22"
// https://mvnrepository.com/artifact/com.google.guava/guava
implementation group: 'com.google.guava', name: 'guava', version: '30.1.1-jre'

View File

@ -16,6 +16,7 @@ public class AssignmentResponse {
@JsonProperty("assignments")
private List<Assignment> assignments;
public AssignmentResponse(Long assignmentCounter, List<Assignment> assignments) {
this.assignmentCounter = assignmentCounter;
this.assignments = assignments;
@ -37,10 +38,12 @@ public class AssignmentResponse {
this.assignments = assignments;
}
@Override
public String toString() {
return "AssignmentResponse{" +
"assignments=" + assignments +
"assignmentCounter=" + assignmentCounter +
", assignments=" + assignments +
'}';
}

View File

@ -1,5 +1,6 @@
package eu.openaire.urls_controller.util;
public interface ControllerConstants {
int ASSIGNMENTS_LIMIT = 10000; // The general assignments-limit the Controller will get. If the worker cannot handle them, then the worker's limit will be applied.

View File

@ -19,8 +19,8 @@ public class FileUtils {
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
public static ThreadLocal<Scanner> inputScanner = new ThreadLocal<Scanner>(); // Every Thread has its own variable.
private static ThreadLocal<Integer> fileIndex = new ThreadLocal<Integer>();
private static ThreadLocal<Integer> unretrievableInputLines = new ThreadLocal<Integer>();
private static final ThreadLocal<Integer> fileIndex = new ThreadLocal<Integer>();
private static final ThreadLocal<Integer> unretrievableInputLines = new ThreadLocal<Integer>();
public static ThreadLocal<Integer> duplicateIdUrlEntries = new ThreadLocal<Integer>();
public static final int jsonBatchSize = 3000;
private static final String utf8Charset = "UTF-8";
@ -62,7 +62,7 @@ public class FileUtils {
/**
* This method decodes a Jason String into its members.
* This method decodes a Json String and returns its members.
* @param jsonLine String
* @return HashMap<String,String>
*/

View File

@ -13,21 +13,19 @@ public class UriBuilder {
public static String baseUrl = null;
public UriBuilder(Environment environment) {
public UriBuilder(Environment environment)
{
baseUrl = "http";
String sslEnabled = environment.getProperty("server.ssl.enabled");
if (sslEnabled == null) { // It's expected to not exist if there is no SSL-configuration.
logger.warn("No property \"server.ssl.enabled\" was found in \"application.properties\". Continuing with plain HTTP..");
sslEnabled = "false";
}
baseUrl += sslEnabled.equals("true") ? "s" : "";
baseUrl += "://";
String hostName = InetAddress.getLoopbackAddress().getHostName(); // Non-null.
baseUrl += hostName;
String serverPort = environment.getProperty("server.port");
if (serverPort == null) { // This is unacceptable!
logger.error("No property \"server.port\" was found in \"application.properties\"!");

View File

@ -16,8 +16,9 @@ server.port = 1880
server.servlet.context-path=/api
# LOGGING LEVELS
logging.level.root=WARN
logging.level.root=INFO
logging.level.org.springframework.web=INFO
logging.level.org.springframework.security=WARN
logging.level.eu.openaire.urls_controller=DEBUG
spring.output.ansi.enabled=always

View File

@ -23,8 +23,8 @@
</encoder>
</appender>
<root level="info">
<appender-ref ref="Console" />
<root level="debug">
<appender-ref ref="Console" /> <!-- TODO - Change it to "File" in production! -->
</root>
</configuration>