Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ specs/
docs
.claude
*.bak
**/test-results/

### Developer's personal properties ###
**/resources/config/application*-dev-*.properties
Expand Down
25 changes: 16 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM maven:3.9-eclipse-temurin-21 AS builder

WORKDIR /code

ARG MAVEN_PROFILE=trexsql
ARG MAVEN_PARAMS="" # can use maven options, e.g. -DskipTests=true -DskipUnitTests=true

ARG OPENTELEMETRY_JAVA_AGENT_VERSION=1.17.0
Expand All @@ -17,8 +16,7 @@ COPY src /code/src
RUN mvn package ${MAVEN_PARAMS} \
-Dpackaging.type=jar \
-Dgit.branch=${GIT_BRANCH} \
-Dgit.commit.id.abbrev=${GIT_COMMIT_ID_ABBREV} \
-P${MAVEN_PROFILE}
-Dgit.commit.id.abbrev=${GIT_COMMIT_ID_ABBREV}

# OHDSI WebAPI running as a Spring Boot executable JAR with Java 21
FROM index.docker.io/library/eclipse-temurin:21-jre
Expand All @@ -40,15 +38,24 @@ RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
COPY --from=builder /code/opentelemetry-javaagent.jar .
COPY --from=builder /code/target/WebAPI.jar .

# Plugin setup: download trexsql-ext plugin JAR
ARG TREXSQL_VERSION=v0.1.23
RUN mkdir -p /opt/webapi/plugins && \
if curl -fL -o /opt/webapi/plugins/trexsql-ext.jar \
"https://github.com/p-hoffmann/trexsql-ext/releases/download/${TREXSQL_VERSION}/trexsql-ext.jar"; then \
echo "Downloaded trexsql-ext plugin ${TREXSQL_VERSION}"; \
else \
echo "WARNING: Failed to download trexsql-ext plugin ${TREXSQL_VERSION}, trexsql will be unavailable"; \
fi

# Extract native lib from plugin JAR
RUN mkdir -p /tmp/trexsql && \
unzip -j WebAPI.jar 'BOOT-INF/lib/trexsql-ext-*.jar' -d /tmp && \
unzip -j /tmp/trexsql-ext-*.jar 'libtrexsql_java.so_linux_amd64' -d /tmp/trexsql 2>/dev/null || true && \
mv /tmp/trexsql/libtrexsql_java.so_linux_amd64 /tmp/trexsql/libtrexsql_java.so 2>/dev/null || true && \
rm -f /tmp/trexsql-ext-*.jar
unzip -j /opt/webapi/plugins/trexsql-ext.jar 'libtrexsql_java.so_linux_amd64' -d /tmp/trexsql 2>/dev/null || true && \
mv /tmp/trexsql/libtrexsql_java.so_linux_amd64 /tmp/trexsql/libtrexsql_java.so 2>/dev/null || true

EXPOSE 8080

USER 101

# Run the executable JAR with TrexSQL native library path
CMD ["sh", "-c", "exec java ${DEFAULT_JAVA_OPTS} ${JAVA_OPTS} -Dorg.duckdb.lib_path=/tmp/trexsql/libtrexsql_java.so --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar WebAPI.jar"]
# Run the executable JAR with plugin directory and TrexSQL native library path
CMD ["sh", "-c", "exec java ${DEFAULT_JAVA_OPTS} ${JAVA_OPTS} -Dloader.path=/opt/webapi/plugins -Dorg.duckdb.lib_path=/tmp/trexsql/libtrexsql_java.so --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar WebAPI.jar"]
2 changes: 1 addition & 1 deletion docker/auth-test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fi
if [ "$BUILD_WEBAPI" = true ]; then
log_info "Building WebAPI..."
cd ../..
mvn clean package -DskipTests -Dpackaging.type=jar -P webapi-postgresql,trexsql -B
mvn clean package -DskipTests -Dpackaging.type=jar -P webapi-postgresql -B
cd "$SCRIPT_DIR"
fi

Expand Down
2 changes: 1 addition & 1 deletion docker/integration-test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fi
if [ "$BUILD_WEBAPI" = true ]; then
log_info "Building WebAPI..."
cd ../..
mvn clean package -DskipTests -Dpackaging.type=jar -P webapi-postgresql,trexsql -B
mvn clean package -DskipTests -Dpackaging.type=jar -P webapi-postgresql -B
cd "$SCRIPT_DIR"
fi

Expand Down
37 changes: 1 addition & 36 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<layout>ZIP</layout>
<addResources>false</addResources>
<includeSystemScope>false</includeSystemScope>
<mainClass>org.ohdsi.webapi.WebApi</mainClass>
Expand Down Expand Up @@ -182,10 +183,6 @@
<!-- Preserve parameter names for reflection (required for AspectJ parameter resolution) -->
<arg>-parameters</arg>
</compilerArgs>
<!-- Exclude TrexSQL sources by default (included when -Ptcache is active) -->
<excludes>
<exclude>**/trexsql/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -900,38 +897,6 @@
</dependencies>

<profiles>
<profile>
<id>trexsql</id>
<properties>
<trexsql.enabled>true</trexsql.enabled>
</properties>
<dependencies>
<dependency>
<groupId>com.github.p-hoffmann</groupId>
<artifactId>trexsql-ext</artifactId>
<version>v0.1.23</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- Include TrexSQL sources when tcache profile is active -->
<excludes combine.self="override"/>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>webapi-oracle</id>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collections;
import java.util.List;

@Component
public class PluginsConfigurationInfo extends ConfigurationInfo {
private static final String KEY = "plugins";

public PluginsConfigurationInfo(@Value("${atlasgis.enabled}") Boolean atlasgisEnabled) {
public PluginsConfigurationInfo(
@Autowired(required = false) List<WebApiPlugin> plugins,
@Value("${atlasgis.enabled}") Boolean atlasgisEnabled) {
if (plugins == null) {
plugins = Collections.emptyList();
}
for (WebApiPlugin plugin : plugins) {
properties.put(plugin.getId() + "Enabled", plugin.isActive());
}
properties.put("atlasgisEnabled", atlasgisEnabled);
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/ohdsi/webapi/plugins/WebApiPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.ohdsi.webapi.plugins;

public interface WebApiPlugin {
String getId();
String getName();
String getVersion();
boolean isActive();
}
8 changes: 5 additions & 3 deletions src/main/java/org/ohdsi/webapi/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ohdsi.webapi.service;

import org.ohdsi.webapi.arachne.logging.event.*;
import org.ohdsi.webapi.plugins.WebApiPlugin;
import org.ohdsi.webapi.shiro.Entities.PermissionEntity;
import org.ohdsi.webapi.shiro.Entities.RoleEntity;
import org.ohdsi.webapi.shiro.Entities.UserEntity;
Expand Down Expand Up @@ -31,8 +32,8 @@ public class UserService {
@Autowired
private ApplicationEventPublisher eventPublisher;

@Value("${trexsql.enabled:false}")
private boolean trexsqlCacheEnabled;
@Autowired(required = false)
private List<WebApiPlugin> plugins = Collections.emptyList();

@Value("${security.auth.ad.default.import.group}#{T(java.util.Collections).emptyList()}")
private List<String> defaultRoles;
Expand Down Expand Up @@ -114,7 +115,8 @@ public User getCurrentUser() throws Exception {
user.name = currentUser.getName();
user.permissions = convertPermissions(permissions);
user.permissionIdx = authorizer.queryUserPermissions(currentUser.getLogin()).permissions;
user.trexsqlCacheEnabled = trexsqlCacheEnabled;
user.trexsqlCacheEnabled = plugins.stream()
.anyMatch(p -> "trexsql".equals(p.getId()) && p.isActive());

return user;
}
Expand Down
38 changes: 0 additions & 38 deletions src/main/java/org/ohdsi/webapi/trexsql/TrexSQLConfig.java

This file was deleted.

117 changes: 0 additions & 117 deletions src/main/java/org/ohdsi/webapi/trexsql/TrexSQLInstanceManager.java

This file was deleted.

Loading