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
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [ push, pull_request ]
env:
MAVEN_OPTS: -Xmx1024M -Xss128M
GECKODRIVER_VERSION: 0.34.0
BIBUTILS_VERSION: 6.10
BIBUTILS_VERSION: 7.2

jobs:
build:
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
export FIREFOX_BIN=$(which firefox-esr)
export SELENIUM_BROWSER=firefox

mvn -B -P!standard-with-extra-repos -U -Djetty clean install
mvn -B -P!standard-with-extra-repos -U -Djetty -e clean install
mvn -P!standard-with-extra-repos -B javadoc:javadoc javadoc:test-javadoc -T1C
- name: Login to Docker Hub
if: contains('refs/heads/2022.06.x refs/heads/2023.06.x refs/heads/main', github.ref) && github.event_name=='push' && success()
Expand Down Expand Up @@ -115,6 +115,7 @@ jobs:
./**/screenshots
./**/*error*.log
./**/*test.log
~/.m2/repository/solr-*/server/logs/*.log

- name: Save Maven cache
uses: skjolber/maven-cache-github-action@v1
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.1'
services:
db:
container_name: ${NAME}-db
image: postgres:12
image: postgres:16
restart: unless-stopped
environment:
- POSTGRES_USER=${DB_USER}
Expand All @@ -15,15 +15,15 @@ services:
- ${DB_PORT}:5432
solr:
container_name: ${NAME}-solr
image: mycoreorg/mir-solr:2022.06.x
image: mycoreorg/mir-solr:2023.06.x
restart: unless-stopped
volumes:
- ${SOLR_DATA}:/var/solr/data
ports:
- ${SOLR_HTTP}:8983
mir:
container_name: ${NAME}-mir
image: mycoreorg/mir:2022.06.x
image: mycoreorg/mir:2023.06.x
restart: unless-stopped
environment:
- APP_CONTEXT=${APP_CONTEXT}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.1'
services:
db:
container_name: ${NAME}-db
image: postgres:12
image: postgres:16
restart: unless-stopped
environment:
- POSTGRES_USER=${DB_USER}
Expand Down
5 changes: 2 additions & 3 deletions mir-it/src/test/java/org/mycore/mir/it/tests/MIRITBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpJdkSolrClient;
import org.apache.solr.client.solrj.request.LukeRequest;
import org.apache.solr.client.solrj.response.LukeResponse;
import org.junit.After;
Expand Down Expand Up @@ -49,8 +49,7 @@ String getCoreName() {
public static void setupSolr() {
int solrPort = Integer.parseInt(System.getProperty("solr.port"));
final String baseSolrUrl = String.format("http://localhost:%d/solr/", solrPort);
SOLR_CLIENT = new HttpSolrClient.Builder()
.withBaseSolrUrl(baseSolrUrl)
SOLR_CLIENT = new HttpJdkSolrClient.Builder(baseSolrUrl)
.build();
}

Expand Down
8 changes: 0 additions & 8 deletions mir-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mycore.frontend.MCRFrontendUtil;
import org.mycore.services.http.MCRHttpUtils;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
Expand All @@ -26,13 +24,11 @@ public class MIRGetOpenAIREProjectsServlet extends HttpServlet {

private static Logger LOGGER = LogManager.getLogger();

private CloseableHttpClient client;
private HttpClient client;

@Override
public void init() throws ServletException {
PoolingHttpClientConnectionManager connectManager = new PoolingHttpClientConnectionManager();
connectManager.setDefaultMaxPerRoute(20);
client = HttpClients.custom().useSystemProperties().setConnectionManager(connectManager).build();
client = MCRHttpUtils.getHttpClient();
}

@Override
Expand All @@ -44,24 +40,29 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
: "acronym=" + URLEncoder.encode(acronym, "UTF-8");
String urlString = "http://api.openaire.eu/search/projects?" + suffix;

HttpGet method = new HttpGet(urlString);
try (CloseableHttpResponse httpRes = client.execute(method)) {
response.setStatus(httpRes.getStatusLine().getStatusCode());
HttpEntity entity = httpRes.getEntity();
try (InputStream contentStream = entity.getContent()) {
IOUtils.copy(contentStream, response.getOutputStream());
HttpRequest openaireRequest = MCRHttpUtils.getRequestBuilder()
.uri(URI.create(urlString))
.build();
boolean transmitted = false;
try {
HttpResponse<InputStream> openaireResponse = client
.send(openaireRequest, HttpResponse.BodyHandlers.ofInputStream());
response.setStatus(openaireResponse.statusCode());
try (InputStream contentStream = openaireResponse.body()) {
contentStream.transferTo(response.getOutputStream());
transmitted = true;
}
} catch (InterruptedException e) {
throw new ServletException(e);
} finally {
if (!transmitted) {
LOGGER.error("Error while loading eternal resource: " + openaireRequest.uri());
}
} catch (IOException e) {
LOGGER.error("Failed to load " + urlString, e);
}
}

@Override
public void destroy() {
try {
client.close();
} catch (IOException e) {
LOGGER.error("Could not close HttpClient!", e);
}
client.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
package org.mycore.mir.authorization;

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jdom2.Attribute;
import org.mycore.common.MCRSessionMgr;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.services.http.MCRHttpUtils;

import com.google.gson.Gson;

Expand Down Expand Up @@ -94,25 +94,24 @@ public Boolean isSubmittedCaptchaCorrect(final HttpServletRequest request) {
}

private Boolean verifyResponse(final String response, final String ip) {
final CloseableHttpClient client = HttpClientBuilder.create().build();
try (HttpClient client = MCRHttpUtils.getHttpClient()) {
final String url = "https://www.google.com/recaptcha/api/siteverify?secret=" + secretKey + "&response="
+ response + "&remoteip=" + ip;

final String url = "https://www.google.com/recaptcha/api/siteverify?secret=" + secretKey + "&response="
+ response + "&remoteip=" + ip;
final HttpRequest get = MCRHttpUtils.getRequestBuilder().uri(URI.create(url)).build();

final HttpGet get = new HttpGet(url);

try {
final HttpResponse res = client.execute(get);
final String json = EntityUtils.toString(res.getEntity());
final HttpResponse<String> res = client.send(get, HttpResponse.BodyHandlers.ofString());
final String json = res.body();

final Gson gson = new Gson();
final ReCaptchaResult rcResult = gson.fromJson(json, ReCaptchaResult.class);

return Boolean.valueOf(rcResult.success);
} catch (final IOException e) {
} catch (final IOException | InterruptedException e) {
LOGGER.warn("ReCaptcha response could not be verified!", e);
return Boolean.FALSE;
}

}

/**
Expand Down
2 changes: 1 addition & 1 deletion mir-webapp/src/main/solr/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM solr:8.11
FROM solr:9.6
USER root
RUN apt-get update && \
apt-get -y install sudo
Expand Down
4 changes: 2 additions & 2 deletions mir-webapp/src/main/solr/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ echo " }" >> $secruity_json
echo " }" >> $secruity_json
echo "}" >> $secruity_json

(/opt/docker-solr/scripts/wait-for-solr.sh;/opt/solr/bin/solr zk cp $secruity_json zk:security.json -z localhost:9983)&
/opt/docker-solr/scripts/solr-foreground -c;
(/opt/solr/docker/scripts/wait-for-solr.sh;/opt/solr/bin/solr zk cp $secruity_json zk:security.json -z localhost:9983)&
/opt/solr/docker/scripts/solr-foreground -c;
23 changes: 20 additions & 3 deletions mir-webapp/src/main/solr/solr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@

More information about options available in this configuration file,
and Solr Core administration can be found online:
https://lucene.apache.org/solr/guide/format-of-solr-xml.html
https://solr.apache.org/guide/solr/latest/configuration-guide/configuring-solr-xml.html
-->

<solr>

<int name="maxBooleanClauses">${solr.max.booleanClauses:1024}</int>
<str name="sharedLib">${solr.sharedLib:}</str>
<str name="modules">${solr.modules:}</str>
<str name="allowPaths">${solr.allowPaths:}</str>
<str name="allowUrls">${solr.allowUrls:}</str>
<str name="hideStackTrace">${solr.hideStackTrace:false}</str>

<solrcloud>

Expand All @@ -45,16 +48,30 @@
<int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
<str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
<str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>
<str name="zkCredentialsInjector">${zkCredentialsInjector:org.apache.solr.common.cloud.DefaultZkCredentialsInjector}</str>
<bool name="distributedClusterStateUpdates">${distributedClusterStateUpdates:false}</bool>
<bool name="distributedCollectionConfigSetExecution">${distributedCollectionConfigSetExecution:false}</bool>
<int name="minStateByteLenForCompression">${minStateByteLenForCompression:-1}</int>
<str name="stateCompressor">${stateCompressor:org.apache.solr.common.util.ZLibCompressor}</str>

</solrcloud>

<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:600000}</int>
<int name="connTimeout">${connTimeout:60000}</int>
<str name="shardsWhitelist">${solr.shardsWhitelist:}</str>
</shardHandlerFactory>

<metrics enabled="${metricsEnabled:true}"/>
<metrics enabled="${metricsEnabled:true}">
<!-- Solr computes JVM metrics for threads. Computing these metrics, esp. computing deadlocks etc.,
requires potentially expensive computations, and can be avoided for every metrics call by
setting a high caching expiration interval (in seconds).
<caching>
<int name="threadsIntervalSeconds">5</int>
</caching>
-->
<!--reporter name="jmx_metrics" group="core" class="org.apache.solr.metrics.reporters.SolrJmxReporter"/-->
</metrics>


</solr>
1 change: 1 addition & 0 deletions mir-webapp/src/main/solr/zoo.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ syncLimit=5
#autopurge.purgeInterval=1

# Disable ZK AdminServer since we do not use it
admin.enableServer=false
13 changes: 6 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@
<!-- until snapshot matches released version (required for 'mvn changes:changes-check') -->
<changes.version>2024.06.0</changes.version>
<java.target.version>21</java.target.version>
<jetty.version>12.0.0</jetty.version>
<jetty.version>12.0.12</jetty.version>
<maven.compiler.arg>-Werror</maven.compiler.arg>
<mycore.version>2024.06.0-SNAPSHOT</mycore.version>
<pmd.version>7.0.0</pmd.version>
<selenium.version>4.3.0</selenium.version>
<site.suffix />
<solr-runner.solrMirrorURL>https://archive.apache.org/dist/lucene/solr/</solr-runner.solrMirrorURL>
<solr-runner.solrVersionString>8.11.2</solr-runner.solrVersionString>
<solr-runner.solrVersionString>9.6.1</solr-runner.solrVersionString>
<sortpom.sortDeps>scope,groupId,artifactId</sortpom.sortDeps>
<sortpom.sortFile>https://gist.githubusercontent.com/yagee-de/dfd3698c1b49173dbf251f74eb6a9297/raw/406460c088ff3cb6354e4ae6b40535e6f841607d/mycore_sort.xml</sortpom.sortFile>
<sortpom.sortProps>true</sortpom.sortProps>
<tomcat.version>10.1.11</tomcat.version>
<tomcat.version>10.1.28</tomcat.version>
</properties>
<build>
<pluginManagement>
Expand All @@ -65,12 +64,12 @@
<plugin>
<groupId>org.mycore.plugins</groupId>
<artifactId>solr-runner-maven-plugin</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4-SNAPSHOT</version>
<configuration>
<solrMirrorURL>${solr-runner.solrMirrorURL}</solrMirrorURL>
<solrVersionString>${solr-runner.solrVersionString}</solrVersionString>
<cloudMode>true</cloudMode>
<verbose>true</verbose>
<cloudMode>true</cloudMode>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
Expand Down
Loading