diff --git a/core/src/test/java/org/fao/geonet/util/XslUtilTest.java b/core/src/test/java/org/fao/geonet/util/XslUtilTest.java index 4be752e7acc..ecfb2cd27aa 100644 --- a/core/src/test/java/org/fao/geonet/util/XslUtilTest.java +++ b/core/src/test/java/org/fao/geonet/util/XslUtilTest.java @@ -41,7 +41,8 @@ public void testHtml2text() { @Test public void testHtml2textSubstituteHtmlToTextLayoutElement() { String html = "
Sample text
Sample text 2
Sample text 3
"; - 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); diff --git a/es/pom.xml b/es/pom.xml index 77d91442f84..3641c20a071 100644 --- a/es/pom.xml +++ b/es/pom.xml @@ -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))) { diff --git a/software_development/INTELLIJ.md b/software_development/INTELLIJ.md index c2bad097e5d..d0507824828 100644 --- a/software_development/INTELLIJ.md +++ b/software_development/INTELLIJ.md @@ -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. @@ -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* diff --git a/software_development/SOURCE.md b/software_development/SOURCE.md index 9a8d8559666..dabaa6cf332 100644 --- a/software_development/SOURCE.md +++ b/software_development/SOURCE.md @@ -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. diff --git a/software_development/TOOLS.md b/software_development/TOOLS.md index 2bd1f556735..077bd00209d 100644 --- a/software_development/TOOLS.md +++ b/software_development/TOOLS.md @@ -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. @@ -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: diff --git a/workers/camelPeriodicProducer/src/test/java/org/fao/geonet/camelPeriodicProducer/MessageProducerTest.java b/workers/camelPeriodicProducer/src/test/java/org/fao/geonet/camelPeriodicProducer/MessageProducerTest.java index c219c0a43c4..34ecd792b83 100644 --- a/workers/camelPeriodicProducer/src/test/java/org/fao/geonet/camelPeriodicProducer/MessageProducerTest.java +++ b/workers/camelPeriodicProducer/src/test/java/org/fao/geonet/camelPeriodicProducer/MessageProducerTest.java @@ -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; @@ -170,16 +172,16 @@ public String getContent() { } } - static public class MessageConsumer { + public static class MessageConsumer { - private Integer count = 0; - private CompletableFuture> future = new CompletableFuture(); - private String uri; - - private List receivedContent = new ArrayList(); + private final String uri; + private AtomicInteger count; + private CompletableFuture> future; + private List receivedContent; public MessageConsumer(String uri) { this.uri = uri; + reset(); } public String getUri() { @@ -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); } } @@ -200,9 +201,9 @@ public List 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<>(); } } } diff --git a/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureDependencyUriLocator.java b/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureDependencyUriLocator.java index 28688568295..dc234e25f94 100644 --- a/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureDependencyUriLocator.java +++ b/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureDependencyUriLocator.java @@ -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(); diff --git a/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureRequireDependencyManager.java b/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureRequireDependencyManager.java index bc286ed52a9..a6d235ae385 100644 --- a/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureRequireDependencyManager.java +++ b/wro4j/src/main/java/org/fao/geonet/wro4j/ClosureRequireDependencyManager.java @@ -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 notMinimized) { boolean isMinimized = true; for (String s : notMinimized) { - if (path.endsWith(s)) { + if (path.endsWith(s) || path.endsWith(s.replace('/', '\\'))) { isMinimized = false; break; } diff --git a/wro4j/src/main/java/org/fao/geonet/wro4j/GeonetWroModelFactory.java b/wro4j/src/main/java/org/fao/geonet/wro4j/GeonetWroModelFactory.java index 5986f32a4a5..73150727649 100644 --- a/wro4j/src/main/java/org/fao/geonet/wro4j/GeonetWroModelFactory.java +++ b/wro4j/src/main/java/org/fao/geonet/wro4j/GeonetWroModelFactory.java @@ -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); } diff --git a/wro4j/src/main/java/org/fao/geonet/wro4j/TemplatesUriLocator.java b/wro4j/src/main/java/org/fao/geonet/wro4j/TemplatesUriLocator.java index 0ccbae5d8f8..c78fcb4d9c2 100644 --- a/wro4j/src/main/java/org/fao/geonet/wro4j/TemplatesUriLocator.java +++ b/wro4j/src/main/java/org/fao/geonet/wro4j/TemplatesUriLocator.java @@ -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); diff --git a/wro4j/src/test/java/org/fao/geonet/wro4j/RemoveSourceMapUrlProcessorTest.java b/wro4j/src/test/java/org/fao/geonet/wro4j/RemoveSourceMapUrlProcessorTest.java index 3bca72b8d16..ffbfe655b2f 100644 --- a/wro4j/src/test/java/org/fao/geonet/wro4j/RemoveSourceMapUrlProcessorTest.java +++ b/wro4j/src/test/java/org/fao/geonet/wro4j/RemoveSourceMapUrlProcessorTest.java @@ -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();