Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code paths that cause errors on Windows #8355

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion core/src/test/java/org/fao/geonet/util/XslUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void testHtml2text() {
@Test
public void testHtml2textSubstituteHtmlToTextLayoutElement() {
String html = "<div><span>Sample text</span><br/><span>Sample text 2</span><br/><span>Sample text 3</span></div>";
String expectedText = "Sample text\nSample text 2\nSample text 3";
String lineSeperator = System.lineSeparator();
String expectedText = "Sample text" + lineSeperator + "Sample text 2" + lineSeperator + "Sample text 3";
String text = XslUtil.html2text(html, true);

assertEquals(expectedText, text);
Expand Down
5 changes: 3 additions & 2 deletions es/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@
kibana = Pattern.compile("kibana:(\\d.\\d\\d.\\d)");
patterns = new Pattern[]{ docker, kibana};

reader = new BufferedReader(new FileReader("${project.basedir}"+"/"+filename));
String baseDir = new File(java.net.URI.create("${project.baseUri}")).getAbsolutePath().toString();
reader = new BufferedReader(new FileReader(baseDir+"/"+filename));

number = 0;
while ((line = reader.readLine()) != null) {
number++;
for (pattern : patterns ){
for (pattern : patterns) {
matcher = pattern.matcher(line);
if (matcher.find()) {
if (!esVersion.equals(matcher.group(1))) {
Expand Down
9 changes: 4 additions & 5 deletions software_development/INTELLIJ.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# IntelliJ IDE

JetBrains provide a the IntelliJ IDE, a community edition is available and
is documented here.
JetBrains provide the IntelliJ IDE, a community edition is available [here](https://www.jetbrains.com/idea/download/).

This IDE is recommended for excellent Maven integration, and very fast build times.
It is especially good at working with large multi-module projects such as GeoNetwork.
Expand All @@ -10,16 +9,16 @@ It is especially good at working with large multi-module projects such as GeoNet

1. Open project in IntelliJ, it will create an `.idea` folder (which is covered by `.gitignore`)

2. Use *File* > *Project Structure* to confirm Java 8 is used
2. Use *File* > *Project Structure* to confirm Java 11 is used.

4. Configuration to make *Maven* tools window easier to follow:
3. Configuration to make *Maven* tools window easier to follow:

* *Group Modules*
* *Always Show ArtifactId*

![configuration](intelij-maven-config.png)

5. Use the *Maven* tools window to:
4. Use the *Maven* tools window to:

* Enable the `env-dev` profile
* *Toggle "Skip Tests" Mode*
Expand Down
3 changes: 1 addition & 2 deletions software_development/SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ cd core-geonetwork
mvn clean install -DskipTests
```

Submodules
----------
## Submodules

GeoNetwork use submodules, these were initialized by the ``--recursive`` option when cloning the repository.

Expand Down
4 changes: 2 additions & 2 deletions software_development/TOOLS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tools

GeoNetwork is a Java Web Application, developed using Java 8, Maven.
GeoNetwork is a Java Web Application, developed using Java and Maven.

Documentation makes use of the python Sphinx build system.

Expand Down Expand Up @@ -68,7 +68,7 @@ Maven repository is available at repo.osgeo.org:

GeoNetwork Reference

* [software_development/building](BUIDLING.md)
* [software_development/building](BUILDING.md)
* [web](../web/README.md)

Reference:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -170,16 +172,16 @@ public String getContent() {
}
}

static public class MessageConsumer {
public static class MessageConsumer {

private Integer count = 0;
private CompletableFuture<List<String>> future = new CompletableFuture();
private String uri;

private List<String> receivedContent = new ArrayList();
private final String uri;
private AtomicInteger count;
private CompletableFuture<List<String>> future;
private List<String> receivedContent;

public MessageConsumer(String uri) {
this.uri = uri;
reset();
}

public String getUri() {
Expand All @@ -189,8 +191,7 @@ public String getUri() {
public void consume(Exchange exchange) {
TestMessage msg = (TestMessage) exchange.getProperty("configuration");
receivedContent.add(msg.getContent());
count++;
if (count > 4) {
if (count.incrementAndGet() > 4) {
future.complete(receivedContent);
}
}
Expand All @@ -200,9 +201,9 @@ public List<String> waitFive() throws InterruptedException, ExecutionException,
}

public void reset() {
count = 0;
receivedContent = new ArrayList();
future = new CompletableFuture();
count = new AtomicInteger(0);
receivedContent = Collections.synchronizedList(new ArrayList<>());
future = new CompletableFuture<>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static Resource createClosureDepResource(ClosureRequireDependencyManager.Node de
resource.setMinimize(false);
resource.setType(ResourceType.JS);

if (Files.exists(IO.toPath(dep.path.replace("file:/D:", "/D")))) {
// If not a URI, but an actual path, set the URI accordingly
if (!dep.path.startsWith("file:/") && Files.exists(IO.toPath(dep.path))) {
resource.setUri(IO.toPath(dep.path).toUri().toString());
} else {
StringBuilder path = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Node addFile(@Nonnull String path, @Nonnull File javascriptFile, @Nonnull
public Node addFile(@Nonnull String path, @Nonnull String javascript, @Nonnull Set<String> notMinimized) {
boolean isMinimized = true;
for (String s : notMinimized) {
if (path.endsWith(s)) {
if (path.endsWith(s) || path.endsWith(s.replace('/', '\\'))) {
isMinimized = false;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,8 @@ private Resource createResourceFrom(ClosureRequireDependencyManager.Node dep) {
Resource resource = new Resource();
resource.setMinimize(dep.isMinimized);
resource.setType(ResourceType.JS);
final Path path = IO.toPath(dep.path.replace("file:/D:", "/D"));
if (Files.exists(path)) {
resource.setUri(path.toUri().toString());
if (!dep.path.startsWith("file:/") && Files.exists(IO.toPath(dep.path))) {
resource.setUri(IO.toPath(dep.path).toUri().toString());
} else {
resource.setUri(dep.path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public InputStream locate(String uri) throws IOException {
} else {
javascript = new StringBuilder();
final String realPath;
final String path = uri.substring(URI_PREFIX.length());
final String path = uri.substring(URI_PREFIX.length()).replace('\\', '/');
final ServletContext servletContext = Context.get().getServletContext();
if (servletContext != null) {
realPath = servletContext.getRealPath(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class RemoveSourceMapUrlProcessorTest {
@Test
public void removeAnnotation() throws Exception {
final String sourceMapAnnotation = "//# sourceMappingURL=this-is-a-test.map";
final String bundledCode = "goog.provide('id');\ngoog.require('id2');\nconsole.log('hello'); console.log('bye');";
final String lineSeparator = System.lineSeparator();
final String bundledCode = "goog.provide('id');"+ lineSeparator + "goog.require('id2');" + lineSeparator + "nconsole.log('hello'); console.log('bye');";
Reader reader = new StringReader(bundledCode + "\n" + sourceMapAnnotation);
StringWriter writer = new StringWriter();
final RemoveSourceMapUrlProcessor processor = new RemoveSourceMapUrlProcessor();
Expand Down