Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id "org.owasp.dependencycheck" version "5.0.0-M3.1"
id "org.owasp.dependencycheck" version "7.1.0.1"
id 'java'
id 'application'
id 'eclipse'
id 'pmd'
id 'checkstyle'
id 'com.github.spotbugs' version '4.5.0'
id 'com.github.spotbugs' version '4.7.1'
}

apply from: 'config/gradle/versioning.gradle'
Expand All @@ -15,6 +15,9 @@ applicationName = "meta-server"

group = 'org.terasology.web'

targetCompatibility = '11'
sourceCompatibility = '11'

repositories {
mavenCentral()

Expand All @@ -26,7 +29,7 @@ repositories {
}

ext {
jettyVersion = '9.4.6.v20170531'
jettyVersion = '9.4.48.v20220622'
}

def codeMetricsDir = "${buildDir}/codeMetrics"
Expand All @@ -42,33 +45,35 @@ dependencies {
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'com.google.code.findbugs:jsr305:3.0.0'

implementation 'org.glassfish.jersey.containers:jersey-container-jetty-servlet:2.22.1'
implementation 'org.glassfish.jersey.ext:jersey-mvc-freemarker:2.22.1'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.3'
implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1'

implementation 'com.google.code.gson:gson:2.4'
implementation 'com.google.guava:guava:18.0'
implementation 'org.glassfish.jersey.containers:jersey-container-jetty-servlet:2.25'
implementation 'org.glassfish.jersey.ext:jersey-mvc-freemarker:2.25'

implementation 'org.jooq:jooq:3.7.0'
implementation 'org.postgresql:postgresql:9.4-1205-jdbc42'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'com.google.guava:guava:31.1-jre'

implementation 'com.squareup.retrofit:retrofit:1.9.0'
implementation 'org.jooq:jooq:3.14.16'
implementation 'org.postgresql:postgresql:42.4.1'

implementation 'org.slf4j:slf4j-api:1.7.13'
implementation 'com.squareup.retrofit:retrofit:1.9.0'

implementation 'com.zaxxer:HikariCP:2.4.1'
implementation 'com.zaxxer:HikariCP:5.0.1'

implementation 'org.terasology:gestalt-module:4.1.2'

testImplementation 'org.jsoup:jsoup:1.8.3'
testImplementation 'com.jcabi:jcabi-w3c:1.3'
testImplementation 'com.jcabi:jcabi-matchers:1.4'
testImplementation 'junit:junit:4.12'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'

testImplementation 'org.jsoup:jsoup:1.15.2'
testImplementation 'com.jcabi:jcabi-w3c:1.4.0'
testImplementation 'com.jcabi:jcabi-matchers:1.5.3'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.h2database:h2:1.4.190'

runtimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'

pmd 'net.sourceforge.pmd:pmd-core:6.27.0'
pmd 'net.sourceforge.pmd:pmd-java:6.27.0'
pmd 'net.sourceforge.pmd:pmd-core:6.48.0'
pmd 'net.sourceforge.pmd:pmd-java:6.48.0'

codeMetrics group: 'org.terasology.config', name: 'codemetrics', version: '1.3.2', ext: 'zip'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Mon Apr 20 18:44:42 CEST 2015
version=2.7.1-SNAPSHOT
version=2.8.0-SNAPSHOT
versioneye.projectkey=maven2_master_server_1
versioneye.projectid=55352d6edc39815abf0007ad
21 changes: 19 additions & 2 deletions src/main/java/org/terasology/web/JettyMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.terasology.web;

import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -77,6 +78,14 @@ public static void main(String[] args) throws Exception {
}
Integer port = Integer.valueOf(portEnv);

String localhostOnlyEnv = System.getenv("LOCALHOST_ONLY");
Boolean localhostOnly = true;
if (localhostOnlyEnv != null) {
localhostOnly = Boolean.valueOf(localhostOnlyEnv);
} else {
logger.warn("Environment variable 'LOCALHOST_ONLY' not defined - using default {}", localhostOnly);
}

String dbEnv = System.getenv("DATABASE_URL");
if (dbEnv == null) {
logger.error("Environment variable 'DATABASE_URL' not defined!");
Expand Down Expand Up @@ -139,6 +148,7 @@ public static void main(String[] args) throws Exception {
ServerListModel serverListModel = new ServerListModelImpl(dataBase, "servers", secret);

Server server = createServer(port.intValue(),
localhostOnly,
new AboutServlet(),
new ServerServlet(serverListModel), // the server list servlet
new ModuleServlet(moduleListModel)); // the module list servlet
Expand All @@ -152,8 +162,15 @@ public static void main(String[] args) throws Exception {
}
}

public static Server createServer(int port, Object... servlets) throws Exception {
Server server = new Server(port);
public static Server createServer(int port, boolean localOnly, Object... servlets) throws Exception {

Server server;

if (localOnly) {
server = new Server(new InetSocketAddress("localhost", port));
} else {
server = new Server(port);
}

ResourceHandler logFileResourceHandler = new ResourceHandler();
logFileResourceHandler.setDirectoriesListed(true);
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/org/terasology/web/model/ModuleListModelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.terasology.web.artifactory.ArtifactInfo;
import org.terasology.web.artifactory.ArtifactRepository;

import com.google.common.collect.ImmutableList;
import com.google.common.io.Files;

/**
Expand All @@ -69,6 +70,8 @@ public class ModuleListModelImpl implements ModuleListModel {

private final Path cacheFolder;

private final List<String> ignoredModules = ImmutableList.of("engine", "engine-tests");

private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);

public ModuleListModelImpl(Path cacheFolder) {
Expand All @@ -93,16 +96,22 @@ public void addRepository(ArtifactRepository repo) {
public void updateAllModules() {
for (ArtifactRepository repo : repositories) {
for (String moduleName : repo.getModuleNames()) {
try {
repo.updateModule(moduleName.toString());
updateModule(repo, moduleName);
} catch (IOException e) {
logger.warn("Could not update module {}", moduleName);
if (isRelevant(moduleName)) {
try {
repo.updateModule(moduleName);
updateModule(repo, moduleName);
} catch (IOException e) {
logger.warn("Could not update module {}", moduleName);
}
}
}
}
}

private boolean isRelevant(String moduleName) {
return !ignoredModules.contains(moduleName);
}

@Override
public void updateModule(Name moduleName) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static void setup() throws Exception {
ServerListModel serverListModel = new ServerListModelImpl(dataBase, SERVER_TABLE, secret);

webServer = JettyMain.createServer(PORT,
true,
new AboutServlet(),
new ServerServlet(serverListModel), // the server list servlet
new ModuleServlet(moduleListModel)); // the module list servlet
Expand Down