Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.2.x' into metawal-4.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Sep 7, 2023
2 parents 88f3ef7 + 2b188b8 commit 7cb1dd0
Show file tree
Hide file tree
Showing 246 changed files with 4,858 additions and 1,987 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches: [ 4.2.x ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [ 4.2.x ]
schedule:
- cron: '44 20 * * 5'

Expand All @@ -38,10 +38,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3

uses: actions/checkout@v4
with:
show-progress: 'false'

- name: Setup Java JDK
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v3.12.0
with:
java-version: 8
# Java distribution. See the list of supported distributions in README file
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ jobs:
- os: ubuntu-22.04
jdk: 8
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# 500 commits, set to 0 to get all
fetch-depth: 500
submodules: 'recursive'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v3.12.0
with:
distribution: 'temurin'
java-version: ${{ matrix.jdk }}
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.6.3
- name: Build with Maven
run: mvn -B -V install -DskipTests=true -Dmaven.javadoc.skip=true
- name: Remove SNAPSHOT jars from repository
Expand All @@ -42,13 +39,14 @@ jobs:
QA:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# 500 commits, set to 0 to get all
fetch-depth: 500
submodules: 'recursive'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v3.12.0
with:
distribution: 'temurin'
java-version: 8
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/mvn-dep-tree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@ name: "MavenDepTreeSubmission"

on:
push:
branches: [ main ]
branches: [ 4.2.x ]
schedule:
- cron: '44 22 * * 5'

jobs:
update-maven-dep-tree:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

uses: actions/checkout@v4
with:
show-progress: 'false'

- name: Setup Java JDK
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v3.12.0
with:
java-version: 8
# Java distribution. See the list of supported distributions in README file
distribution: temurin
# The package type (jdk, jre, jdk+fx, jre+fx)
java-package: jdk
cache: maven

- name: Submit Dependency Snapshot
uses: advanced-security/maven-dependency-submission-action@v3
11 changes: 5 additions & 6 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: SonarCloud QA
on:
push:
branches:
- main
- 4.0.x
- 3.12.x
- 4.2.x
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand All @@ -15,16 +13,17 @@ jobs:
# https://github.community/t/how-to-detect-a-pull-request-from-a-fork/18363/4
if: github.event.pull_request.head.repo.fork != true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: 'recursive'
show-progress: 'false'
# For building GeoNetwork, JDK8 is necessary, but for running
# the SonarQube plugin, JDK11 is necessary.
# So, first install JDK 8, build GeoNetwork, then install JDK11
# and run SonarQube:
- name: Set up JDK 8
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v3.12.0
with:
java-version: 8
distribution: 'temurin'
Expand All @@ -38,7 +37,7 @@ jobs:
- name: Build GN
run: mvn -B package -DskipTests
- name: Set up JDK 11
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v3.12.0
with:
distribution: 'temurin'
java-version: '11'
Expand Down
2 changes: 1 addition & 1 deletion cachingxslt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>4.2.5-SNAPSHOT</version>
<version>4.2.6-SNAPSHOT</version>
</parent>


Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>4.2.5-SNAPSHOT</version>
<version>4.2.6-SNAPSHOT</version>
</parent>


Expand Down
24 changes: 12 additions & 12 deletions common/src/main/java/org/fao/geonet/utils/AbstractHttpRequest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2023 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down Expand Up @@ -83,7 +83,7 @@ public class AbstractHttpRequest {
private boolean useProxy;
private String proxyHost;
private int proxyPort;
private ArrayList<NameValuePair> alSimpleParams = new ArrayList<NameValuePair>();
private ArrayList<NameValuePair> alSimpleParams = new ArrayList<>();
private String postData;
private boolean preemptiveBasicAuth;
private HttpClientContext httpClientContext;
Expand Down Expand Up @@ -303,9 +303,9 @@ protected HttpRequestBase setupHttpMethod() throws IOException {
}

if (host == null || protocol == null) {
throw new IllegalStateException(String.format(getClass().getSimpleName() + " is not ready to be executed: \n\tprotocol: '%s' " +
throw new IllegalStateException(String.format("%s is not ready to be executed: \n\tprotocol: '%s' " +
"\n\tuserinfo: '%s'\n\thost: '%s' \n\tport: '%s' \n\taddress: '%s'\n\tquery '%s'" +
"\n\tfragment: '%s'", protocol, userInfo, host, port, address, query, fragment));
"\n\tfragment: '%s'", getClass().getSimpleName(), protocol, userInfo, host, port, address, query, fragment));
}

HttpRequestBase httpMethod;
Expand Down Expand Up @@ -352,25 +352,25 @@ protected HttpRequestBase setupHttpMethod() throws IOException {

protected String getSentData(HttpRequestBase httpMethod) {
URI uri = httpMethod.getURI();
StringBuilder sentData = new StringBuilder(httpMethod.getMethod()).append(" ").append(uri.getPath());
StringBuilder sentDataValue = new StringBuilder(httpMethod.getMethod()).append(" ").append(uri.getPath());

if (uri.getQuery() != null) {
sentData.append("?" + uri.getQuery());
sentDataValue.append("?" + uri.getQuery());
}

sentData.append("\r\n");
sentDataValue.append("\r\n");

for (Header h : httpMethod.getAllHeaders()) {
sentData.append(h);
sentDataValue.append(h);
}

sentData.append("\r\n");
sentDataValue.append("\r\n");

if (httpMethod instanceof HttpPost) {
sentData.append(postData);
sentDataValue.append(postData);
}

return sentData.toString();
return sentDataValue.toString();
}

private Element soapEmbed(Element elem) {
Expand All @@ -393,7 +393,7 @@ protected Element soapUnembed(Element envelope) throws BadSoapResponseEx {

List<Element> list = body.getChildren();

if (list.size() == 0)
if (list.isEmpty())
throw new BadSoapResponseEx(envelope);

return list.get(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2023 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down Expand Up @@ -200,6 +200,7 @@ public HttpClientBuilder getDefaultHttpClientBuilder() {
final HttpClientBuilder builder = HttpClientBuilder.create();
builder.setRedirectStrategy(new LaxRedirectStrategy());
builder.disableContentCompression();
builder.useSystemProperties();

synchronized (this) {
if (connectionManager == null) {
Expand Down Expand Up @@ -249,40 +250,40 @@ public void closeIdleConnections(long idleTimeout, TimeUnit tunit) {

private static class AdaptingResponse extends AbstractClientHttpResponse {

private final CloseableHttpResponse _response;
private final CloseableHttpClient _client;
private final CloseableHttpResponse response;
private final CloseableHttpClient client;

public AdaptingResponse(CloseableHttpClient client, CloseableHttpResponse response) {
this._response = response;
this._client = client;
this.response = response;
this.client = client;
}

@Override
public int getRawStatusCode() throws IOException {
return _response.getStatusLine().getStatusCode();
return response.getStatusLine().getStatusCode();
}

@Override
public String getStatusText() throws IOException {
return _response.getStatusLine().getReasonPhrase();
return response.getStatusLine().getReasonPhrase();
}

@Override
public void close() {
IOUtils.closeQuietly(_response);
IOUtils.closeQuietly(_client);
IOUtils.closeQuietly(response);
IOUtils.closeQuietly(client);
}

@Override
public InputStream getBody() throws IOException {
return _response.getEntity().getContent();
return response.getEntity().getContent();
}

@Override
public HttpHeaders getHeaders() {
final HttpHeaders httpHeaders = new HttpHeaders();

final Header[] headers = _response.getAllHeaders();
final Header[] headers = response.getAllHeaders();

for (Header header : headers) {
final HeaderElement[] elements = header.getElements();
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<artifactId>geonetwork</artifactId>
<groupId>org.geonetwork-opensource</groupId>
<version>4.2.5-SNAPSHOT</version>
<version>4.2.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@
import org.fao.geonet.NodeInfo;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.kernel.setting.Settings;
import org.fao.geonet.constants.Geonet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.apache.commons.lang3.StringUtils;
import org.fao.geonet.kernel.setting.SettingInfo;


import java.io.IOException;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -84,8 +88,10 @@ protected String determineTargetUrl(HttpServletRequest request, HttpServletRespo

String siteHost = settingManager.getValue(Settings.SYSTEM_SERVER_HOST);
String siteProtocol = settingManager.getValue(Settings.SYSTEM_SERVER_PROTOCOL);
int sitePort = settingManager.getValueAsInt(Settings.SYSTEM_SERVER_PORT);


// some conditional logic to handle the case where there's no port in the settings
SettingInfo si = new SettingInfo();
int sitePort = si.getSitePort();

if (!hostName.equalsIgnoreCase(siteHost) ||
!protocol.equalsIgnoreCase(siteProtocol) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/
package org.fao.geonet.kernel;

import org.fao.geonet.NodeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockHttpSession;
Expand All @@ -43,16 +41,19 @@

public class SpringLocalServiceInvoker {

@Autowired
public RequestMappingHandlerMapping requestMappingHandlerMapping;
public final RequestMappingHandlerMapping requestMappingHandlerMapping;

@Autowired
public RequestMappingHandlerAdapter requestMappingHandlerAdapter;
public final RequestMappingHandlerAdapter requestMappingHandlerAdapter;

private HandlerMethodArgumentResolverComposite argumentResolvers;
private HandlerMethodReturnValueHandlerComposite returnValueHandlers;
private DefaultDataBinderFactory webDataBinderFactory;

public SpringLocalServiceInvoker(RequestMappingHandlerMapping requestMappingHandlerMapping, RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
this.requestMappingHandlerMapping = requestMappingHandlerMapping;
this.requestMappingHandlerAdapter = requestMappingHandlerAdapter;
}

public void init() {
argumentResolvers = new HandlerMethodArgumentResolverComposite().addResolvers(requestMappingHandlerAdapter.getArgumentResolvers());
returnValueHandlers = new HandlerMethodReturnValueHandlerComposite().addHandlers(requestMappingHandlerAdapter.getReturnValueHandlers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ public void indexMetadata(final String metadataId,
fields.put(IndexFields.DRAFT, "n");
fields.put(IndexFields.INDEXING_ERROR_FIELD, true);
fields.put(IndexFields.INDEXING_ERROR_MSG, String.format(
"Schema '%s' is not registerd in this catalog. Install it or remove those records",
"Schema '%s' is not registered in this catalog. Install it or remove those records",
schema
));
searchManager.index(null, md, indexKey, fields, metadataType,
forceRefreshReaders, indexingMode);
Log.error(Geonet.DATA_MANAGER, String.format(
"Record %s / Schema '%s' is not registerd in this catalog. Install it or remove those records. Record is indexed indexing error flag.",
"Record %s / Schema '%s' is not registered in this catalog. Install it or remove those records. Record is indexed indexing error flag.",
metadataId, schema));
} else {

Expand Down
Loading

0 comments on commit 7cb1dd0

Please sign in to comment.